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

Support query variable #142

Closed
dinoboff opened this issue Jan 31, 2018 · 5 comments
Closed

Support query variable #142

dinoboff opened this issue Jan 31, 2018 · 5 comments

Comments

@dinoboff
Copy link
Collaborator

dinoboff commented Jan 31, 2018

The rule parser and evaluator needs to allow it and APIs needs a way to set it.

It's not yet part of the security variables reference but there's a blog post and a guide entry:

@dinoboff
Copy link
Collaborator Author

dinoboff commented Feb 17, 2018

query.orderByChild default value should be null according the the guide, but query.orderByChild != null is currently an invalid statement. And although, the other orderBy attributes default value should be false, query.orderByValue != null is valid.

I opened an issue with Firebase to check if it's a bug before accommodating for the new inferring requirement.

@dinoboff
Copy link
Collaborator Author

dinoboff commented Mar 5, 2018

The firebase issue is now fixed, and query.orderByKey, query.orderByValue and query.orderByPriority still support comparison to null which match targaryen behaviour with auth property access.

@dinoboff
Copy link
Collaborator Author

dinoboff commented Mar 6, 2018

With #144, you can set query in chai with:

targaryen.setFirebaseData(null);
targaryen.setFirebaseRules({rules: {
  '.read': 'query.orderByChild == "owner" && query.equalTo == auth.uid'
}});

expect({uid: 'bob'}).can.readWith({query: {
  orderByChild: 'owner',
  equalTo: 'bob'
}}).path('/');

With jasmine:

targaryen.setFirebaseData(null);
targaryen.setFirebaseRules({rules: {
  '.read': 'query.orderByChild == "owner" && query.equalTo == auth.uid'
}});

expect({uid: 'bob'}).canRead('/', {query: {
  orderByChild: 'owner',
  equalTo: 'bob'
}});

I will release in 3.1.0-beta.1 before committing to those assertion methods.

@dinoboff
Copy link
Collaborator Author

dinoboff commented Mar 7, 2018

You can try the new matcher/options with npm install targaryen@beta

@dinoboff dinoboff modified the milestone: 3.1.0 May 13, 2018
@dinoboff
Copy link
Collaborator Author

Published with v3.1.0.

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

No branches or pull requests

1 participant