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

Extended options are supported for listing resources 80 #92

Merged

Conversation

jtuttle
Copy link
Member

@jtuttle jtuttle commented Jul 10, 2017

Fixes #80.

@ghost ghost assigned jtuttle Jul 10, 2017
@ghost ghost added the review label Jul 10, 2017
@apotterri apotterri closed this Jul 10, 2017
@ghost ghost removed the review label Jul 10, 2017
@apotterri apotterri reopened this Jul 10, 2017
@ghost ghost assigned apotterri Jul 10, 2017
@ghost ghost added the review label Jul 10, 2017
@dustinmm80
Copy link
Contributor

@jtuttle
Copy link
Member Author

jtuttle commented Jul 10, 2017

Build fixed!

# Search only the user's account.
# This can be removed once resource visibility rules are added.
scope = scope.where("account(resource_id) = ?", account)
scope = scope.where(Sequel.lit("account(resource_id) = ?", account))
Copy link
Member Author

Choose a reason for hiding this comment

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

This and any similar changes were made to address deprecation warnings (from Sequel I believe).

Copy link
Contributor

Choose a reason for hiding this comment

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

Gee, you read my mind.... I was wondering what this was doing here.

This change to the default behavior of Sequel doesn't seem as necessary when it's used to implement an API. (SQL injection doesn't seem like that much of an issue for us.) I wonder if we should add the auto_literal_strings extension.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah you're probably right, I think we could safely include the auto_literal_strings extension since we're not using the API to server external users. Maybe that could be a separate story, though.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can make it into a separate story, but then let's not make this change (even though it causes a deprecation warning).

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, will undo these changes.

@jtuttle jtuttle removed the request for review from kgilpin July 13, 2017 17:07
end

Given(/^I create a new searchable resource(?: called "([^"]*)")?$/) do |identifier|
kind ||= "test-resource"
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no kind param to this block.

# Search only the user's account.
# This can be removed once resource visibility rules are added.
scope = scope.where("account(resource_id) = ?", account)
scope = scope.where(Sequel.lit("account(resource_id) = ?", account))
Copy link
Contributor

Choose a reason for hiding this comment

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

Gee, you read my mind.... I was wondering what this was doing here.

This change to the default behavior of Sequel doesn't seem as necessary when it's used to implement an API. (SQL injection doesn't seem like that much of an issue for us.) I wonder if we should add the auto_literal_strings extension.


Scenario: Resource list includes a new resource

The most basic resource listing route returns all resources in an account.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment probably shouldn't get deleted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, added it back.


Scenario: The resource list can be filtered by resource kind.
Given I create a new resource
Copy link
Contributor

Choose a reason for hiding this comment

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

With the repetition of the Given clauses in this feature, it seems like there are two sets of scenarios here: one for a single resource, and one for a collection of resources.

I think you should split them up into two separate files.

Copy link
Member Author

Choose a reason for hiding this comment

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

What if we don't bother explicitly testing the single resource case? It doesn't seem super necessary, plus the name of feature is "List resources with various types of filtering", which implies multiple resources anyways.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I think I found a decent way to do this in a single file while still testing the single-result case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I'm ok with getting rid of creating a single resource. So, we can get rid of the first scenario, but we need to keep the second two (testing for filtering by resource kind).

When I successfully GET "/resources/cucumber/test-resource?search=target"
Then the resource list should only include the searched resources

Scenario: The resource list is filtered by limit.
Copy link
Contributor

Choose a reason for hiding this comment

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

"filtered by limit" and "filtered by offset" seem like awkward ways of describing what's happening.

Copy link
Member Author

Choose a reason for hiding this comment

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

Very true. I've reworded these.

end

Given(/^I create a new searchable resource(?: called "([^"]*)")?$/) do |identifier|
kind ||= "test-resource"
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no kind parameter for this block, so there's no need for ||= here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point! Removed.

@@ -0,0 +1,112 @@
Sequel.migration do
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this take verbatim from authz? If not, could you add some comments here about what you changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had to make a couple changes. Will document them.

@@ -1,20 +1,66 @@
@logged-in
Feature: List resources with various types of filtering
Feature: List resources and filter by the kind parameter
Copy link
Contributor

Choose a reason for hiding this comment

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

This was ok the way it was -- these scenarios do more than test filter by kind.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, yep. I changed this when I was trying to split things into two files and forgot to change it back. Will fix.

@apotterri apotterri merged commit 8e1655c into master Jul 13, 2017
@ghost ghost removed the review label Jul 13, 2017
@apotterri apotterri deleted the extended-options-are-supported-for-listing-resources-80 branch July 13, 2017 19:29
conjur-jenkins pushed a commit that referenced this pull request Sep 13, 2024
…st-CNJR-1428

Skip flaky test in http proxy
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