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

[API] Endpoint to create policies #593

Merged
merged 11 commits into from Feb 28, 2019
Merged

[API] Endpoint to create policies #593

merged 11 commits into from Feb 28, 2019

Conversation

Martouta
Copy link
Contributor

@Martouta Martouta commented Feb 12, 2019

Fixes THREESCALE-1910 - API Endpoint to create policies

Specific tasks

I recommend looking at it commit by commit.

@Martouta Martouta self-assigned this Feb 12, 2019
@codecov
Copy link

codecov bot commented Feb 12, 2019

Codecov Report

Merging #593 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #593      +/-   ##
==========================================
- Coverage   92.74%   92.74%   -0.01%     
==========================================
  Files        2355     2357       +2     
  Lines       76244    76239       -5     
==========================================
- Hits        70710    70705       -5     
  Misses       5534     5534
Impacted Files Coverage Δ
...ion/admin/api/registry/policies_controller_test.rb 100% <100%> (ø)
...trollers/admin/api/registry/policies_controller.rb 100% <100%> (ø)
config/routes.rb 98% <100%> (ø) ⬆️
app/indices/account_index.rb 94.11% <0%> (-0.33%) ⬇️
test/unit/account/search_test.rb 100% <0%> (ø) ⬆️
spec/acceptance/api/user_spec.rb
spec/acceptance/api/feature_spec.rb 100% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7017a79...5b76347. Read the comment docs.

@codecov
Copy link

codecov bot commented Feb 12, 2019

Codecov Report

Merging #593 into master will increase coverage by 0.03%.
The diff coverage is 99.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #593      +/-   ##
==========================================
+ Coverage   92.75%   92.78%   +0.03%     
==========================================
  Files        2355     2367      +12     
  Lines       76299    76668     +369     
==========================================
+ Hits        70768    71137     +369     
  Misses       5531     5531
Impacted Files Coverage Δ
...rollers/admin/api/member_permissions_controller.rb 95% <ø> (ø) ⬆️
...ers/admin/api/personal/access_tokens_controller.rb 100% <ø> (ø) ⬆️
app/lib/three_scale/policies/specification.rb 100% <100%> (ø)
...ion/admin/api/registry/policies_controller_test.rb 100% <100%> (ø)
test/unit/member_permission_test.rb 100% <100%> (ø) ⬆️
app/models/account/provider_methods.rb 91.06% <100%> (+0.05%) ⬆️
config/abilities/provider_any.rb 100% <100%> (ø) ⬆️
app/models/admin_section.rb 100% <100%> (ø) ⬆️
test/unit/admin_section_test.rb 100% <100%> (ø) ⬆️
config/routes.rb 98% <100%> (ø) ⬆️
... and 34 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b08ec3f...5742226. Read the comment docs.

@Martouta Martouta force-pushed the api-policies-create branch 7 times, most recently from e1d0ec9 to 869905d Compare February 13, 2019 14:39
@Martouta
Copy link
Contributor Author

Martouta commented Feb 13, 2019

[OUTDATED]

So far I've done this:
image
image

Request: curl -v -X POST "http://provider-admin.example.com.lvh.me:3000/admin/api/registry/policies.json" -d 'access_token=f46d02db1502511135bd11e54fad2505c40877236c24f23369b667a24c3bf7d9&name=example+name&version=example+version&schema=%7Bexample%3A+'Example+without+validating+the+JSON+at+this+point'%7D'
Response:

{
 "policy": {
  "id": 1,
  "name": "example name",
  "version": "example version",
  "schema": "{example: 'Example without validating the JSON at this point'}",
  "created_at": "2019-02-13T14:11:57Z",
  "updated_at": "2019-02-13T14:11:57Z"
 }
}

gemfiles/prod/Gemfile.lock Outdated Show resolved Hide resolved
@@ -1,6 +1,6 @@
import { fetchRegistry } from 'Policies/actions/PolicyRegistry'

describe('Policy Registry Actions', () => {
describe('Policies Registry Actions', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

PolicyRegistry actions would be more accurate, since the component it refers to the component.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get what you mean by

the component it refers to the component.

"Policies Registry" was an attempt to make it clear it is about a registry of possible multiple custom policies, as opposed to a single policy registry. Even though "Policies Registry" is not grammatically incorrect AFAIK, it's probably a good thing to keep it "Policy Registry" as you said for consistency with other (most) API endpoints that also describe actions on collections of records.

Currently most of the API endpoints are in the form "Item Collection" (singular-singular), such as "Invoice List" instead of "Invoices List". Although we do have exceptions already, like "Account Features List" (plural-singular). The current endpoint to fetch APIcast policies spells it "APIcast Policies Registry" (plural-singular). I think I'll have to change that too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also change the name of the rolling update and the name of the member permission section?

cc @josemigallas @hallelujah @secretsurf @thomasmaas

Copy link
Member

Choose a reason for hiding this comment

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

It feels that we might want to refactor at some point to keep consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

Changed everything to "policy registry", including the title of the already existing API endpoint
"APIcast Policies Registry" (now "APIcast Policy Registry")

Copy link
Contributor

@josemigallas josemigallas left a comment

Choose a reason for hiding this comment

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

Variables in JS are named in cammelCase. Otherwise LGTM.

Martouta and others added 11 commits February 28, 2019 12:01
NOT NULL constraint to fields of policies table
[policies] Instance variable set in the test to what it says it does

split big test in multiple ones
… must be a tenant

Policy validation method renamed to belongs_to_a_tenant

ThreeScale JSON Validator

Changed 'path' to 'glob' in ThreeScale::Policies::Specification

file_fixture test helper
[Part 1] Rolling update to enable this because this will be deployed in SaaS 1st. Disabled for master.

Authorize Rolling Update Policies & Not Master to Create a policy through the API. With CanCan

[Part 2] Rolling update to enable this because this will be deployed in SaaS 1st.

Rolling update feature policy_registry

Check if account is tenant first in apidocs services controller

Removed unnecessary mixin from apidocs services controller

Refactor policy_registry rolling updates and ability
Copy link
Contributor

@hallelujah hallelujah left a comment

Choose a reason for hiding this comment

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

Looks good
There are some things that could be refactored but minor

@guicassolato guicassolato merged commit 037665b into master Feb 28, 2019
@guicassolato guicassolato deleted the api-policies-create branch February 28, 2019 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants