mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-04 08:42:01 +02:00
fixes as per review comments
This commit is contained in:
@@ -907,7 +907,7 @@ func TestCrossNamespacedSecrets(t *testing.T) {
|
||||
|
||||
err := cluster.initRobotUsers()
|
||||
if err != nil {
|
||||
t.Errorf("%s Could not create namespaced users with error: %s", testName, err)
|
||||
t.Errorf("Could not create secret for namespaced users with error: %s", err)
|
||||
}
|
||||
|
||||
for _, u := range cluster.pgUsers {
|
||||
@@ -920,7 +920,7 @@ func TestCrossNamespacedSecrets(t *testing.T) {
|
||||
func TestValidUsernames(t *testing.T) {
|
||||
testName := "test username validity"
|
||||
|
||||
invalidUsernames := []string{"_", ".", ".user", "appspace.", "appspace.user.extra", "user_", "_user", "-user", "user-", ",", ",user", "user,", "namespace,user"}
|
||||
invalidUsernames := []string{"_", ".", ".user", "appspace.", "appspace.user.extra", "user_", "_user", "-user", "user-", ",", "-", ",user", "user,", "namespace,user"}
|
||||
|
||||
for _, username := range invalidUsernames {
|
||||
if isValidUsername(username) {
|
||||
|
||||
+16
-3
@@ -556,13 +556,26 @@ func (c *Cluster) syncRoles() (err error) {
|
||||
|
||||
// create list of database roles to query
|
||||
for _, u := range c.pgUsers {
|
||||
pg_role := u.Name
|
||||
pgRole := u.Name
|
||||
if u.Namespace != c.Namespace {
|
||||
// to avoid the conflict of having multiple users of same name
|
||||
// but each in different namespace.
|
||||
pg_role = fmt.Sprintf("%s.%s", u.Name, u.Namespace)
|
||||
pgRole = fmt.Sprintf("%s.%s", u.Name, u.Namespace)
|
||||
}
|
||||
userNames = append(userNames, pgRole)
|
||||
// add team member role name with rename suffix in case we need to rename it back
|
||||
if u.Origin == spec.RoleOriginTeamsAPI && c.OpConfig.EnableTeamMemberDeprecation {
|
||||
deletedUsers[u.Name+c.OpConfig.RoleDeletionSuffix] = u.Name
|
||||
userNames = append(userNames, u.Name+c.OpConfig.RoleDeletionSuffix)
|
||||
}
|
||||
}
|
||||
|
||||
// add team members that exist only in cache
|
||||
// to trigger a rename of the role in ProduceSyncRequests
|
||||
for _, cachedUser := range c.pgUsersCache {
|
||||
if _, exists := c.pgUsers[cachedUser.Name]; !exists {
|
||||
userNames = append(userNames, cachedUser.Name)
|
||||
}
|
||||
userNames = append(userNames, pg_role)
|
||||
}
|
||||
|
||||
// add pooler user to list of pgUsers, too
|
||||
|
||||
Reference in New Issue
Block a user