Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed Apr 30, 2018
1 parent d590fc7 commit 7b4ab17
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
test/fixtures/copy
test/fixtures/invalid
test/fixtures/outside
34 changes: 34 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var test = require('tape')
var rimraf = require('rimraf')
var tar = require('../index')
var tarStream = require('tar-stream')
var path = require('path')
var fs = require('fs')
var os = require('os')
Expand Down Expand Up @@ -310,3 +311,36 @@ test('do not extract invalid tar', function (t) {
})
})
})

test('no abs hardlink targets', function (t) {
var out = path.join(__dirname, 'fixtures', 'invalid')
var outside = path.join(__dirname, 'fixtures', 'outside')

rimraf.sync(out)

var s = tarStream.pack()

fs.writeFileSync(outside, 'something')

s.entry({
type: 'link',
name: 'link',
linkname: outside
})

s.entry({
name: 'link'
}, 'overwrite')

s.finalize()

s.pipe(tar.extract(out))
.on('error', function (err) {
t.ok(err, 'had error')
fs.readFile(outside, 'utf-8', function (err, str) {
t.error(err, 'no error')
t.same(str, 'something')
t.end()
})
})
})

0 comments on commit 7b4ab17

Please sign in to comment.