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

Auth 1840/configure project limit #2029

Merged
merged 13 commits into from
Oct 30, 2019
Merged

Conversation

blakestier
Copy link

@blakestier blakestier commented Oct 29, 2019

🔩 Description: What code changed, and why?

⛓️ Related Resources

👍 Definition of Done

👟 How to Build and Test the Change

rebuild components/authz-service
rebuild components/automate-deployment
rebuild components/automate-cli

touch authz.toml

authz.toml contents:

[auth_z.v1.sys.service]
project_limit = 7

chef-automate config patch authz.toml

Attempt to make more than 7 custom projects 💁(curl -XPOST -d '{"name":"test", "id":"foo1-project"}' -H "api-token: $TOK" $TARGET_HOST/apis/iam/v2beta/projects --insecure)

✅ Checklist

  • Tests added/updated?
  • Docs added/updated?

📷 Screenshots, if applicable

@susanev susanev added the auth-team anything that needs to be on the auth team board label Oct 29, 2019
@blakestier blakestier marked this pull request as ready for review October 29, 2019 19:02
Copy link
Contributor

@bcmdarroch bcmdarroch left a comment

Choose a reason for hiding this comment

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

Code looks good so far! I would add a few more tests.

After rebuilding authz and deployment I tried to exercise it with these commands (from #1840) but either my toml is wrong or I haven't rebuilt something.

[8][default:/src:93]# cat <<EOF > authz2.toml
[authz.v1.sys.svc]
project_limit = 300
EOF

[9][default:/src:0]# chef-automate config patch authz2.toml
ConfigError: The configuration is invalid: Config file must be a valid automate config: unknown configuration keys:
    authz.v1.sys.svc
    authz.v1.sys.svc.project_limit

@@ -4410,7 +4410,9 @@ func TestCreateProject(t *testing.T) {
}
resp, err := store.CreateProject(ctx, &oneProjectTooMany)
assert.Nil(t, resp)
assert.Equal(t, storage_errors.ErrMaxProjectsExceeded, err)
assert.Error(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

could we add a test for configuring a different value for the project limit?

Copy link
Author

@blakestier blakestier Oct 29, 2019

Choose a reason for hiding this comment

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

we can't without refactoring the whole test suite :D but i'll do it for you if you want

lol it was not bad 😂

api/config/deployment/automate_config_test.go Outdated Show resolved Hide resolved
@susanev
Copy link
Contributor

susanev commented Oct 29, 2019

yah i also couldnt get that patch to work, but ive never tried to do that before either so maybe im doing something wrong

@blakestier blakestier force-pushed the auth-1840/configure-project-limit branch 3 times, most recently from 8006a7c to e5fa1ed Compare October 29, 2019 22:24
@blakestier blakestier force-pushed the auth-1840/configure-project-limit branch 2 times, most recently from 02ef144 to 0e7bbb0 Compare October 30, 2019 15:23
Copy link
Contributor

@msorens msorens 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! Just a few minor suggestions.

@@ -136,3 +136,15 @@ function install_go_tool() {
fi
done
}

document "revendor" <<DOC
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this do?

Copy link
Author

Choose a reason for hiding this comment

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

@msorens I pulled this in from #2039. Needed it to successfully update the bldr.toml


if projectLimit != nil {
if limit := projectLimit.GetValue(); limit < constants_v2.MaxProjects {
e := errors.Errorf("invalid project limit of %v: must be minimum of %v", limit, constants_v2.MaxProjects)
Copy link
Contributor

Choose a reason for hiding this comment

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

Using "minimum" to describe a maximum seems confusing. Also, consider using a shorter phrase, e.g., just:

"project limit must be at least %v"

// MaxProjectsExceededError indicates that a new project cannot be created
// since the max allowed are already created.
func (e *MaxProjectsExceededError) Error() string {
return fmt.Sprintf("violates project limit of %v", e.projectLimit)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not clear what context is provided along with this text. But assuming this is the entirety of what the user sees, consider including the info in the comment on L83-84, e.g.

"cannot create project: limit of %v projects already reached"

Blake Johnson and others added 12 commits October 30, 2019 10:46
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Ryan Cragun <ryan@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Blake Johnson <bstier@chef.io>
Signed-off-by: Ryan Cragun <ryan@chef.io>
@blakestier blakestier force-pushed the auth-1840/configure-project-limit branch from 0b475e8 to bd60e4f Compare October 30, 2019 17:46
Signed-off-by: Blake Johnson <bstier@chef.io>
Copy link
Contributor

@bcmdarroch bcmdarroch left a comment

Choose a reason for hiding this comment

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

sweet 👍 👍

@blakestier blakestier merged commit 7bb175e into master Oct 30, 2019
@blakestier blakestier deleted the auth-1840/configure-project-limit branch October 30, 2019 20:31
@sdelano
Copy link

sdelano commented Nov 1, 2019

closes #2076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth-team anything that needs to be on the auth team board
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants