"use strict";


var authHelper = require('../../lib/auth-helper.js');


describe.only('GET /auth', function() {

  var self = this;

  before(function(done) {
    request
      .get('/auth')
      .end(function(err, res) {
        self.err = err;
        self.res = res;
        if (self.res.text) {
          self.$ = cheerio.load(self.res.text);
        }
        done(err);
      });
  });

  context('When requesting the list of identity provider', function() {

    it('should return a status 200', function() {
      expect(self.res.statusCode).to.equal(200);
    });

    it('should return HTML', function() {
      expect(self.res.headers['content-type']).to.equal('text/html; charset=utf-8');
    });

    describe('the response body', function() {

      it('should display links for every enabled idp', function() {

        var enabled_idp_list = authHelper.getEnabledIdentityProviders();

        for (var idp_label in enabled_idp_list) {
          var link = self.$('a.identity_provider.' + idp_label);
          expect(link.length).to.not.equal(0);

          //Clean class in order to identify disabled idp
          link.removeClass('identity_provider').addClass(idp_label);
        }
      });

      it('should display only enabled idp', function(){
        expect(self.$('a.identity_provider').length).to.equal(0);
      });

    });

  });
});

@@ -8,17 +8,16 @@
 rict%22;%0A%0A
-%0A
 var auth
@@ -59,11 +59,8 @@
 lper
-.js
 ');%0A
@@ -812,25 +812,24 @@
 unction() %7B%0A
-%0A
         var 
@@ -1343,18 +1343,962 @@
    %7D);%0A%0A
-
   %7D);%0A
+%0A%7D);%0A%0A%0Adescribe.only('GET /protected', function() %7B%0A%0A  var self = this;%0A%0A%0A  var sendRequest = function(done) %7B%0A    request%0A      .get('/protected')%0A      .end(function(err, res) %7B%0A        self.err = err;%0A        self.res = res;%0A        done(err);%0A      %7D);%0A  %7D;%0A%0A  var sendAuthenticatedRequest = function(done) %7B%0A    request%0A      .get('/protected')%0A      .set('Authorization', 'Bearer '+ TEST_AUTHORIZATION_TOKEN)%0A      .end(function(err, res) %7B%0A        self.err = err;%0A        self.res = res;%0A        done(err);%0A      %7D);%0A  %7D;%0A%0A  context('When the user is not authenticated', function() %7B%0A%0A    before(sendRequest);%0A%0A    it('should return a status 401', function() %7B%0A      expect(self.res.statusCode).to.equal(401);%0A    %7D);%0A  %7D);%0A%0A  context('When the user is authenticated', function() %7B%0A%0A    before(sendAuthenticatedRequest);%0A%0A    it('should return a status 200', function() %7B%0A      expect(self.res.statusCode).to.equal(200);%0A    %7D);%0A%0A  %7D);%0A%0A
 %7D);%0A

Test /protected