Skip to content

Commit 0ca353c

Browse files
DEVOPS-27631: Fix command that grants access to a role (#288)
* update command * fix tests * extra command
1 parent cfe3e27 commit 0ca353c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/dbclient/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ func (pc *client) CreateReadOnlyRole(dbName, rolename, schema string) (bool, err
549549

550550
func (pc *client) AssignRoleToUser(username, rolename string) error {
551551
db := pc.DB
552-
if _, err := db.Exec(fmt.Sprintf("GRANT %s TO %s", pq.QuoteIdentifier(rolename), pq.QuoteIdentifier(username))); err != nil {
552+
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 {
553553
return err
554554
}
555555

pkg/roleclaim/roleclaim_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ func TestDBRoleClaimController_RevokeRolesAndAssignNew(t *testing.T) {
259259
defer close()
260260

261261
viperObj.Set("passwordconfig::passwordRotationPeriod", 60)
262+
viperObj.Set("defaultMasterUsername", "root")
263+
viperObj.Set("defaultMasterPort", "5432")
264+
viperObj.Set("defaultSslMode", "require")
265+
viperObj.Set("defaultMinStorageGB", "10")
266+
viperObj.Set("defaultSslMode", "disable")
262267

263268
test := struct {
264269
rec reconciler

0 commit comments

Comments
 (0)