Skip to content

Commit

Permalink
DEVOPS-27631: Fix command that grants access to a role (#288)
Browse files Browse the repository at this point in the history
* update command

* fix tests

* extra command
  • Loading branch information
EvertonCalgarotto authored Aug 27, 2024
1 parent cfe3e27 commit 0ca353c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/dbclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ func (pc *client) CreateReadOnlyRole(dbName, rolename, schema string) (bool, err

func (pc *client) AssignRoleToUser(username, rolename string) error {
db := pc.DB
if _, err := db.Exec(fmt.Sprintf("GRANT %s TO %s", pq.QuoteIdentifier(rolename), pq.QuoteIdentifier(username))); err != nil {
if _, err := db.Exec(fmt.Sprintf("ALTER ROLE %s SET ROLE TO %s;GRANT %s TO %s;", pq.QuoteIdentifier(username), pq.QuoteIdentifier(rolename), pq.QuoteIdentifier(rolename), pq.QuoteIdentifier(username))); err != nil {
return err
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/roleclaim/roleclaim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ func TestDBRoleClaimController_RevokeRolesAndAssignNew(t *testing.T) {
defer close()

viperObj.Set("passwordconfig::passwordRotationPeriod", 60)
viperObj.Set("defaultMasterUsername", "root")
viperObj.Set("defaultMasterPort", "5432")
viperObj.Set("defaultSslMode", "require")
viperObj.Set("defaultMinStorageGB", "10")
viperObj.Set("defaultSslMode", "disable")

test := struct {
rec reconciler
Expand Down

0 comments on commit 0ca353c

Please sign in to comment.