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

test updated to check status 400 for create user without role #74

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions quest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,6 @@ func TestSmoke_AllUsersAPI(t *testing.T) {
AssertRole(t, NewGlob.QueryClient, "dummyrole", dummyRole)

CreateUser(t, NewGlob.QueryClient, "dummyuser")
AssignRolesToUser(t, NewGlob.QueryClient, "dummyuser", []string{"dummyrole"})
AssertUserRole(t, NewGlob.QueryClient, "dummyuser", "dummyrole", dummyRole)
RegenPassword(t, NewGlob.QueryClient, "dummyuser")
DeleteUser(t, NewGlob.QueryClient, "dummyuser")

Copy link
Member

Choose a reason for hiding this comment

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

why removing all this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CreateUser will fail without the role, hence AssignRolesToUser will not work.
There are two more tests -

  1. TestSmoke_NewUserNoRole - that should give 400 status
  2. TestSmokeRbacBasic - that creates user with role which should give 200 status

Copy link
Member

Choose a reason for hiding this comment

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

why can't we add the role in the CreateUser call?

CreateUserWithRole(t, NewGlob.QueryClient, "dummyuser", []string{"dummyrole"})
AssertUserRole(t, NewGlob.QueryClient, "dummyuser", "dummyrole", dummyRole)
RegenPassword(t, NewGlob.QueryClient, "dummyuser")
Expand All @@ -431,14 +426,7 @@ func TestSmoke_NewUserNoRole(t *testing.T) {
SetDefaultRole(t, NewGlob.QueryClient, "dummyrole")
AssertDefaultRole(t, NewGlob.QueryClient, "\"dummyrole\"")

password := CreateUser(t, NewGlob.QueryClient, "dummyuser")
userClient := NewGlob.QueryClient
userClient.Username = "dummyuser"
userClient.Password = password

PutSingleEventExpectErr(t, userClient, NewGlob.Stream)

DeleteUser(t, NewGlob.QueryClient, "dummyuser")
CreateUser(t, NewGlob.QueryClient, "dummyuser")
DeleteStream(t, NewGlob.QueryClient, NewGlob.Stream)

}
Expand Down
2 changes: 1 addition & 1 deletion test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func CreateUser(t *testing.T, client HTTPClient, user string) string {
response, err := client.Do(req)
require.NoErrorf(t, err, "Request failed: %s", err)
body := readAsString(response.Body)
require.Equalf(t, 200, response.StatusCode, "Server returned http code: %s and response: %s", response.Status, body)
require.Equalf(t, 400, response.StatusCode, "Server returned http code: %s resp %s", response.Status, readAsString(response.Body))
return body
}

Expand Down
Loading