Skip to content

Commit

Permalink
Refining the basic auth tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Aug 24, 2014
1 parent ec5359d commit f126fd3
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions test/tenso_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,11 @@ describe("Hypermedia", function () {
describe("Basic Auth", function () {
var port = 8004;

tenso( {port: port, routes: routes, logs: {level: "error"}, auth: {basic: {enabled: true, list:["test:123"]}, protect: ["/"]}} );
tenso( {port: port, routes: routes, logs: {level: "error"}, auth: {basic: {enabled: true, list:["test:123"]}, protect: ["/uuid"]}} );

describe( "GET /", function () {
it( "returns an array of endpoints (authorized)", function ( done ) {
it( "returns links", function ( done ) {
api( port )
.auth('test', '123')
.get( "/" )
.expectStatus( 200 )
.expectValue( "data.link", [{uri:'http://localhost:8004/items', rel:'related'}] )
Expand All @@ -275,10 +274,26 @@ describe("Basic Auth", function () {
} );
} );

describe( "GET /", function () {
describe( "GET /uuid", function () {
it( "returns a uuid (authorized)", function ( done ) {
api( port )
.auth('test', '123')
.get( "/uuid" )
.expectStatus( 200 )
.expectValue( "data.link", [] )
.expectValue( "error", null )
.expectValue( "status", 200 )
.end( function ( err ) {
if ( err ) throw err;
done();
} );
} );
} );

describe( "GET /uuid", function () {
it( "returns an 'unauthorized' error", function ( done ) {
api( port, true )
.get( "/" )
.get( "/uuid" )
.expectStatus( 401 )
.end( function ( err ) {
if ( err ) throw err;
Expand Down

0 comments on commit f126fd3

Please sign in to comment.