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

Added possibility to define cookie path parameter #2 #1201

Merged
merged 1 commit into from
Feb 14, 2017

Conversation

IgorKvasn
Copy link
Contributor

replacement for a bad PR #1196

@@ -148,6 +161,8 @@ export default BaseStore.extend({
init() {
this._super(...arguments);

this.set('_cookiePath', Configuration.baseURL);
Copy link
Member

Choose a reason for hiding this comment

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

This should only be set when it is null (as it might have been set when the cookie store instance was created with Cookie.create({ cookiePath: '/whatever' }) and shouldn't be overridden in this case).


const { assign: emberAssign, merge, run } = Ember;
const assign = emberAssign || merge;

describe('AdaptiveStore', () => {
let store;

beforeEach(function() {
Configuration.load({ baseURL: '/' });
Copy link
Member

Choose a reason for hiding this comment

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

Why is this required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tests in cookie-store-behaviour.js expect that cookie path is set to '/' e.g.
https://github.com/simplabs/ember-simple-auth/blob/master/tests/unit/session-stores/shared/cookie-store-behavior.js#L110

I guess there are 2 ways to sort this out - either change it in all asserts from path === '/' to path === Configuration.baseURL or just set a default baseURL for all tests (which I did)

Copy link
Member

Choose a reason for hiding this comment

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

I see. I'd just set the cookiePath property on the created store instance instead (here) in these cases so the test is independent of the Configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, that's probably a better option then to globally force this setting to all tests

@@ -17,6 +18,7 @@ describe('CookieStore', () => {

beforeEach(function() {
store = createCookieStore(FakeCookieService.create());
Configuration.load({ baseURL: '/' });
Copy link
Member

Choose a reason for hiding this comment

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

Why is this required?

@IgorKvasn
Copy link
Contributor Author

hmm there are some regression tests failing (at least that's how I understood Travis) - I guess to make it backwards compatible, cookie path should be null by default (or to be precise - do not add any cookie path at all)

@IgorKvasn
Copy link
Contributor Author

nope, fastboot tests are failing

@marcoow
Copy link
Member

marcoow commented Feb 8, 2017

I guess to make it backwards compatible, cookie path should be null by default (or to be precise - do not add any cookie path at all)

You are right - defaulting to / would actually be a breaking change:
https://tools.ietf.org/html/rfc6265#section-4.1.2.4

@marcoow
Copy link
Member

marcoow commented Feb 13, 2017

@IgorKvasn: can you rebase on master?

@@ -218,7 +229,7 @@ export default BaseStore.extend({
let cookieOptions = {
domain: this.get('cookieDomain'),
expires: isEmpty(expiration) ? null : new Date(expiration),
path: '/',
path: this.get('cookiePath'),
Copy link
Member

@marcoow marcoow Feb 14, 2017

Choose a reason for hiding this comment

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

Hm, this is actually a breaking change. We'll need to default the property to '/' instead (as opposed to what I said above this was already the default previously and that obviously has to stay that way).

Copy link
Member

Choose a reason for hiding this comment

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

I fixed it

@marcoow marcoow merged commit 8101ab3 into mainmatter:master Feb 14, 2017
@marcoow marcoow modified the milestones: 1.3, 1.2.1 Mar 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants