Skip to content

Instantly share code, notes, and snippets.

@jedwood
Last active July 4, 2016 23:55
Show Gist options
  • Save jedwood/5311084 to your computer and use it in GitHub Desktop.
Save jedwood/5311084 to your computer and use it in GitHub Desktop.
API Testing Example - Part 1
describe('Authentication', function() {
it('errors if wrong basic auth', function(done) {
api.get('/blog')
.set('x-api-key', '123myapikey')
.auth('incorrect', 'credentials')
.expect(401, done)
});
it('errors if bad x-api-key header', function(done) {
api.get('/blog')
.auth('correct', 'credentials')
.expect(401)
.expect({error:"Bad or missing app identification header"}, done);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment