Skip to content
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

TK2d #508

Merged
merged 1 commit into from
Oct 11, 2016
Merged

TK2d #508

merged 1 commit into from
Oct 11, 2016

Conversation

ricardopereira
Copy link
Contributor

No description provided.

@@ -14,10 +14,16 @@

ART_ASSUME_NONNULL_BEGIN

@protocol ARTDefaultTokenParams <NSObject>
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I don't think this is a sound solution. This isn't really buying us anything, as we can in fact set defaultTokenParams to an ARTTokenParams with timestamp, and then we just force-convert defaultTokenParams back to ARTTokenParams (here), so the timestamp would still be there! (Plus, that's generally a type-unsafe conversion.)

I don't think it really pays off to introduce a new type for this; you can just check on defaultTokenParams's setter that timestamp is nil.

But if you want to introduce a new type to ensure this at compile time, I think ARTDefaultTokenParams shouldn't be a protocol but a class, with a public interface just like ARTTokenParams but without a timestamp property. That would ensure that we don't have a timestamp there, of course. It should have a method toTokenParams to be used in the line above that returns an ARTTokenParams with a nil timestamp. (Implementation suggestion: ARTDefaultTokenParams could have a ARTTokenParams private property or instance variable to which it would just delegate all calls, and then return it when toTokenParams is called.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, the protocol is not a good solution. You can access the timestamp with a simple hack performSelector("getTimestamp").

Initially I was thinking to just assign nil to the timestamp on the defaultTokenParams setter but then I faced failures with this spec. Now I was looking to the 0.8 specs and I can't find anything related with TokenParams .timestamp should be generated at the getter and stick.

@ricardopereira
Copy link
Contributor Author

@tcard PTAL

Copy link
Contributor

@tcard tcard left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@mattheworiordan mattheworiordan left a comment

Choose a reason for hiding this comment

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

Unless I have misunderstood I think we're setting the timestamp too early in the process for TokenParams.

let params = ARTTokenParams()

waitUntil(timeout: testTimeout) { done in
let now = NSDate().artToIntegerMs()
guard let timestamp = params.timestamp else {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure I follow this. If a user creates a TokenParams object, if I am reading this correctly, you are setting a timestamp as part of the token params. So if the user then did something async, and later did an auth using the TokenParams, the timestamp woudl be the timestamp the TokenParams object was created? If so, that is wrong. The vanilla TokenParams object has no timestamp value unless explicitly set. Then when a token request is issued, if the TokenParams object has a value it uses it, if not the current timestamp is used. There is no benefit in issuing a timestamp when the TokenParams object is initialized whatsoever, it will simply mean that it's more likely that by the time a token request is created, the timestamp will be out of date.

Copy link
Contributor Author

@ricardopereira ricardopereira Oct 10, 2016

Choose a reason for hiding this comment

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

@mattheworiordan Yes, I changed the TokenParams initialiser to always include a timestamp.

TokenParams object has no timestamp value unless explicitly set

I will fix it.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, glad we spotted this then :/

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 0624ee2.

@ricardopereira
Copy link
Contributor Author

Can I squash and rebase?

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

Successfully merging this pull request may close these issues.

3 participants