-
Notifications
You must be signed in to change notification settings - Fork 1
BasicIdToken files #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,105 @@ | |||
| 'use strict'; | |||
| const Message = require('../message'); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the Message class defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has not been reviewed it. Since you requested to have only one PR at a time I thought I
would start with BasicIdToken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, we should have started with Message or Token since this depends on it. It's hard for me to review without knowing anything about these classes. Also your tests will fail and nothing will compile when you merge this PR. Would it be possible to send parallel PRs for these 2 classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| @@ -0,0 +1,105 @@ | |||
| 'use strict'; | |||
| const Message = require('../message'); | |||
| const Token = require('./token'); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is token defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has not been reviewed it. Since you requested to have only one PR at a time I thought I
would start with BasicIdToken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Send me the PR for Token to review in parallel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| @@ -0,0 +1,105 @@ | |||
| 'use strict'; | |||
| const Message = require('../message'); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, if you are using ES6, why not use ES6 import instead of require:
import * as Message from '../message';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Will have to change this in a lot of places through out the library. I can make the change, but is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make sense to be consistent. You already implemented this in es6.
It would also make sense to do that early in the process. It will get harder later on. You can keep it as is for now and do it in a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. On my todo list as need to add additional setting up to enable this.
| * @class | ||
| * @constructor | ||
| * @extends Message | ||
| * @param {*} iss |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor seems to accept one parameter object {iss, sub, iat, jti}. The javadoc here is not correct.
Also shouldn't all these parameter types by string instead of *?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see your change. Did you forget to commit it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't pushed the changes yet. Will update you once I push them
| ]; | ||
|
|
||
| /** Known required claims */ | ||
| this.knownOptionalClaims = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property and the ones below it seem like they could be defined as an array like this.optionsForObjects.
forEach can also be used to iterate over an array.
Is this the format as defined in the Message class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
test/basicId-claims-test.js
Outdated
| @@ -0,0 +1,226 @@ | |||
| var fs = require('fs'); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You seem to be using ES5 for the unit tests. Why not stick to ES6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Will push the commit after the other tasks are complete
test/basicId-claims-test.js
Outdated
| @@ -0,0 +1,226 @@ | |||
| var fs = require('fs'); | |||
| var path = require('path'); | |||
| var assert = require('chai').assert; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using chai.expect.
It is easier to assert if some call throws an error without having to try/catch.
eg:
expect(() => {
failingCallback();
}).to.throw('Some error');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my todo list
| }, | ||
| {'clockTimestamp': clockTimestamp}) | ||
| } catch (err) { | ||
| assert.isNull(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you expecting this to be called? It is not clear what the expectation here is. I would expect that you are testing that the function call succeeds.
A cleaner way is to use expect().to.throw() here and below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect does not seem to work well with async functions compared to asserts
test/basicId-claims-test.js
Outdated
| .catch(function(err) { | ||
| assert.isNull(err); | ||
| }); | ||
| done(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For asynchronous tests, done should be called when the promise completes. You are calling it prematurely ehre and elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Will push the commit after the other tasks are complete
| }); | ||
| basicIdToken.addOptionalClaims(optionalClaims); | ||
| if (options && Object.keys(options).indexOf('algorithm') !== -1 && | ||
| options['algorithm'] === 'none') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a unit test for this to confirm algorithm is set to none automatically
No description provided.