Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bug fixing

  • Loading branch information...
commit 5ffbec680ee986cca91ced654aa1f423677e39c1 1 parent 2e504f9
@sperreault sperreault authored
Showing with 28 additions and 36 deletions.
  1. +19 −9 lib/openam.js
  2. +9 −27 tests/openam.js
View
28 lib/openam.js
@@ -75,29 +75,39 @@ exports.OpenAm.prototype.authenticate= function (username, password, callback){
var results = {};
try {
results = querystring.parse( data);
- }
- catch (e) {
+ }
+ catch (e) {
/*
* TODO need to impement in case of attributes query;
*/
console.log(e);
- }
- var token = results['token.id'];
- callback(null, token);
+ }
+ callback(null, results['token.id']);
}
});
}
exports.OpenAm.prototype.logout= function (token, callback){
-
+ this._request(this._getLogoutUrl(token), function( error, data, reponse){
+ console.log(data);
+ callback(error);
+ });
}
exports.OpenAm.prototype.isTokenValid= function(token, callback) {
this._request(this._getTokenValidUrl(token), function(error, data, response) {
- console.log(data);
if ( error ) callback(false);
- if ( data ) callback(data['boolean']);
- else callback(false);
+ var results = {};
+ if ( data ) {
+ results = querystring.parse( data);
+ if (results['boolean'] == 'true') {
+ callback(true);
+ } else {
+ callback(false);
+ }
+ } else {
+ callback(false);
+ }
});
}
View
36 tests/openam.js
@@ -1,32 +1,14 @@
-var vows = require('vows'),
- assert = require('assert'),
- OpenAm= require('../lib/openam').OpenAm;
-
var baseSite = 'http://sebasp.alesium.net/openam/';
var username = 'demo';
var goodPassword = 'demodemo';
-var badPassword = 'demode';
-vows.describe('OpenAm').addBatch({
- 'openam':{
- topic: new OpenAm(baseSite),
- 'should return login UI url' : function (openam){
- assert.equal(openam.getLoginUiUrl(), baseSite + 'UI/Login?');
- },
- 'should return logout UI url' : function (openam){
- assert.equal(openam.getLogoutUiUrl(), baseSite +'UI/Logout?');
- },
- },
- 'authenticate' : {
- topic: new OpenAm(baseSite),
- 'Good password' : function (topic){
- topic.authenticate(username,goodPassword,function( error, token){
- assert.equal(error,null);
- topic.isTokenValid(token, function( isValid ){
- assert.equal(isValid,true);
- });
- })
- },
- },
+var OpenAm = require('../lib/openam.js').OpenAm,
+ assert = require('assert');
+
+
+var openAm = new OpenAm(baseSite);
+
-}).export(module);
+var token = openAm.authenticate(username,goodPassword, function(error, token, res) {
+ assert.equal(error,null);
+});
Please sign in to comment.
Something went wrong with that request. Please try again.