Skip to content

Conversation

@anjuthomas
Copy link
Contributor

No description provided.

@anjuthomas anjuthomas requested a review from bojeil-google May 17, 2018 22:22
@@ -0,0 +1,105 @@
'use strict';
const Message = require('../message');
Copy link
Collaborator

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?

Copy link
Contributor Author

@anjuthomas anjuthomas May 24, 2018

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

@anjuthomas anjuthomas May 26, 2018

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');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is token defined?

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

@anjuthomas anjuthomas May 26, 2018

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');
Copy link
Collaborator

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';

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

@anjuthomas anjuthomas May 26, 2018

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
Copy link
Collaborator

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 *?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Collaborator

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?

Copy link
Contributor Author

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 = {
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -0,0 +1,226 @@
var fs = require('fs');
Copy link
Collaborator

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?

Copy link
Contributor Author

@anjuthomas anjuthomas May 29, 2018

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

@@ -0,0 +1,226 @@
var fs = require('fs');
var path = require('path');
var assert = require('chai').assert;
Copy link
Collaborator

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');

Copy link
Contributor Author

@anjuthomas anjuthomas May 29, 2018

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);
Copy link
Collaborator

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

Copy link
Contributor Author

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

.catch(function(err) {
assert.isNull(err);
});
done();
Copy link
Collaborator

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.

Copy link
Contributor Author

@anjuthomas anjuthomas May 26, 2018

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') {
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants