Skip to content

Commit

Permalink
chore(codeclimate): fix "duplicate" shits, nah hate that...
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Oct 7, 2016
1 parent b12b1d9 commit eebda02
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ test('should have `opts.id` and it should be binded to koa this', function (done
}
}))

request(server)
.get('/')
request(server).get('/')
.expect('x-github-username', 'tunnckoCore')
.expect(200, 'Hello World')
.end(done)
Expand All @@ -51,24 +50,18 @@ test('should `403 Forbidden` if not match to `opts.filter`', function (done) {
filter: '1.2.3.*'
}))

request(server)
.get('/')
.set('x-koaip', '4.4.8.8')
.expect(403, '403 Forbidden')
.end(done)
request(server).get('/').set('x-koaip', '4.4.8.8')
.expect(403, '403 Forbidden').end(done)
})

test('should `403 Forbidden` if IP is in blacklist', function (done) {
var server = middleware(ipFilter({
request(middleware(ipFilter({
id: function () {
return this.request.header['x-koaip']
},
filter: ['*', '!89.???.30.*']
}))

request(server)
.get('/')
.set('x-koaip', '89.111.30.8')
})))
.get('/').set('x-koaip', '89.111.30.8')
.expect(403, '403 Forbidden')
.end(done)
})
Expand All @@ -83,9 +76,7 @@ test('should `200 OK` if not in blacklist range', function (done) {
// or *.*.*.*
filter: ['*.*.*.*', '!111.??.244.*']
})
var server = middleware(mw)

request(server)
request(middleware(mw))
.get('/')
.set('x-koaip', '4.4.8.8')
.expect(200, 'Hello World')
Expand Down Expand Up @@ -170,8 +161,7 @@ test('should not have `this.filter` if no `opts.filter` given', function (done)

request(server)
.get('/')
.expect(200, 'Hello World')
.end(function (err) {
.expect(200, 'Hello World').end(function (err) {
test.ifError(err)
test.equal(ok, true)
done()
Expand Down

0 comments on commit eebda02

Please sign in to comment.