Skip to content

Commit 1cfa303

Browse files
arthurpitmand0weinberger
authored andcommitted
feat(account): Enable MONACO_FEAT_SERVICE_USERS feature flag by default
1 parent ac9cf6b commit 1cfa303

File tree

3 files changed

+53
-21
lines changed

3 files changed

+53
-21
lines changed

internal/featureflags/temporary.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var temporaryDefaultValues = map[FeatureFlag]defaultValue{
6060
OpenPipeline: true,
6161
IgnoreSkippedConfigs: false,
6262
Segments: true,
63-
ServiceUsers: false,
63+
ServiceUsers: true,
6464
OnlyCreateReferencesInStringValues: false,
6565
ServiceLevelObjective: true,
6666
AccessControlSettings: false,

pkg/account/delete/loader_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ func TestLoader_BasicAllTypesSucceeds(t *testing.T) {
8282
}
8383

8484
func TestLoader_ServiceUserProducesErrorWithoutFeatureFlag(t *testing.T) {
85+
t.Setenv(featureflags.ServiceUsers.EnvName(), "false")
86+
8587
fs, deleteFilename := newMemMapFsWithDeleteFile(t, `delete:
8688
- type: serviceUser
8789
name: my-service-user`)
@@ -90,6 +92,16 @@ func TestLoader_ServiceUserProducesErrorWithoutFeatureFlag(t *testing.T) {
9092
assert.Error(t, err)
9193
}
9294

95+
func TestLoader_ServiceUserProducesNoErrorWithFeatureFlag(t *testing.T) {
96+
t.Setenv(featureflags.ServiceUsers.EnvName(), "true")
97+
fs, deleteFilename := newMemMapFsWithDeleteFile(t, `delete:
98+
- type: serviceUser
99+
name: my-service-user`)
100+
101+
_, err := delete.LoadResourcesToDelete(fs, deleteFilename)
102+
assert.NoError(t, err)
103+
}
104+
93105
func TestLoader_NoEntriesSucceeds(t *testing.T) {
94106
fs, deleteFilename := newMemMapFsWithDeleteFile(t, `delete:`)
95107

pkg/account/downloader/downloader_test.go

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ func TestDownloader_EmptyAccount(t *testing.T) {
5252
client.EXPECT().GetPolicies(gomock.Any(), accountUUID).Return([]accountmanagement.PolicyOverview{}, nil)
5353
client.EXPECT().GetGroups(gomock.Any(), accountUUID).Return([]accountmanagement.GetGroupDto{}, nil)
5454
client.EXPECT().GetUsers(gomock.Any(), accountUUID).Return([]accountmanagement.UsersDto{}, nil)
55-
// Once temporary featureflags.ServiceUsers is removed, uncomment the following:
56-
//client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
55+
// Once temporary featureflags.ServiceUsers is removed, remove the following:
56+
if featureflags.ServiceUsers.Enabled() {
57+
client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
58+
}
5759

5860
result, err := downloader.DownloadResources(t.Context())
5961
assert.NoError(t, err)
@@ -88,8 +90,10 @@ func TestDownloader_AccountPolicy(t *testing.T) {
8890

8991
client.EXPECT().GetGroups(gomock.Any(), accountUUID).Return([]accountmanagement.GetGroupDto{}, nil)
9092
client.EXPECT().GetUsers(gomock.Any(), accountUUID).Return([]accountmanagement.UsersDto{}, nil)
91-
// Once temporary featureflags.ServiceUsers is removed, uncomment the following:
92-
//client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
93+
// Once temporary featureflags.ServiceUsers is removed, remove the following:
94+
if featureflags.ServiceUsers.Enabled() {
95+
client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
96+
}
9397

9498
result, err := downloader.DownloadResources(t.Context())
9599
assert.NoError(t, err)
@@ -137,8 +141,10 @@ func TestDownloader_EnvironmentPolicy(t *testing.T) {
137141

138142
client.EXPECT().GetGroups(gomock.Any(), accountUUID).Return([]accountmanagement.GetGroupDto{}, nil)
139143
client.EXPECT().GetUsers(gomock.Any(), accountUUID).Return([]accountmanagement.UsersDto{}, nil)
140-
// Once temporary featureflags.ServiceUsers is removed, uncomment the following:
141-
//client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
144+
// Once temporary featureflags.ServiceUsers is removed, remove the following:
145+
if featureflags.ServiceUsers.Enabled() {
146+
client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
147+
}
142148

143149
result, err := downloader.DownloadResources(t.Context())
144150
assert.NoError(t, err)
@@ -182,8 +188,10 @@ func TestDownloader_GlobalPolicy(t *testing.T) {
182188

183189
client.EXPECT().GetGroups(gomock.Any(), accountUUID).Return([]accountmanagement.GetGroupDto{}, nil)
184190
client.EXPECT().GetUsers(gomock.Any(), accountUUID).Return([]accountmanagement.UsersDto{}, nil)
185-
// Once temporary featureflags.ServiceUsers is removed, uncomment the following:
186-
//client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
191+
// Once temporary featureflags.ServiceUsers is removed, remove the following:
192+
if featureflags.ServiceUsers.Enabled() {
193+
client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
194+
}
187195

188196
result, err := downloader.DownloadResources(t.Context())
189197
assert.NoError(t, err)
@@ -233,8 +241,10 @@ func TestDownloader_OnlyUser(t *testing.T) {
233241
client.EXPECT().GetGroups(gomock.Any(), accountUUID).Return([]accountmanagement.GetGroupDto{}, nil)
234242
client.EXPECT().GetUsers(gomock.Any(), accountUUID).Return([]accountmanagement.UsersDto{{Email: "usert@some.org"}}, nil)
235243
client.EXPECT().GetGroupsForUser(gomock.Any(), "usert@some.org", accountUUID).Return(&accountmanagement.GroupUserDto{Email: "usert@some.org"}, nil)
236-
// Once temporary featureflags.ServiceUsers is removed, uncomment the following:
237-
//client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
244+
// Once temporary featureflags.ServiceUsers is removed, remove the following:
245+
if featureflags.ServiceUsers.Enabled() {
246+
client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
247+
}
238248

239249
result, err := downloader.DownloadResources(t.Context())
240250
assert.NoError(t, err)
@@ -271,8 +281,10 @@ func TestDownloader_UserWithOneGroup(t *testing.T) {
271281
Email: "usert@some.org",
272282
Groups: []accountmanagement.AccountGroupDto{{Uuid: groupUUID1}},
273283
}, nil)
274-
// Once temporary featureflags.ServiceUsers is removed, uncomment the following:
275-
//client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
284+
// Once temporary featureflags.ServiceUsers is removed, remove the following:
285+
if featureflags.ServiceUsers.Enabled() {
286+
client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
287+
}
276288

277289
result, err := downloader.DownloadResources(t.Context())
278290
assert.NoError(t, err)
@@ -332,8 +344,10 @@ func TestDownloader_EmptyGroup(t *testing.T) {
332344
client.EXPECT().GetPermissionFor(gomock.Any(), accountUUID, gomock.Any()).Return(&accountmanagement.PermissionsGroupDto{}, nil)
333345

334346
client.EXPECT().GetUsers(gomock.Any(), accountUUID).Return([]accountmanagement.UsersDto{}, nil)
335-
// Once temporary featureflags.ServiceUsers is removed, uncomment the following:
336-
//client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
347+
// Once temporary featureflags.ServiceUsers is removed, remove the following:
348+
if featureflags.ServiceUsers.Enabled() {
349+
client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
350+
}
337351

338352
result, err := downloader.DownloadResources(t.Context())
339353
assert.NoError(t, err)
@@ -371,8 +385,10 @@ func TestDownloader_GroupWithFederatedAttributeValues(t *testing.T) {
371385
client.EXPECT().GetPermissionFor(gomock.Any(), accountUUID, gomock.Any()).Return(&accountmanagement.PermissionsGroupDto{}, nil)
372386

373387
client.EXPECT().GetUsers(gomock.Any(), accountUUID).Return([]accountmanagement.UsersDto{}, nil)
374-
// Once temporary featureflags.ServiceUsers is removed, uncomment the following:
375-
//client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
388+
// Once temporary featureflags.ServiceUsers is removed, remove the following:
389+
if featureflags.ServiceUsers.Enabled() {
390+
client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
391+
}
376392

377393
result, err := downloader.DownloadResources(t.Context())
378394
assert.NoError(t, err)
@@ -459,8 +475,10 @@ func TestDownloader_GroupsWithPolicies(t *testing.T) {
459475
}, nil)
460476

461477
client.EXPECT().GetUsers(gomock.Any(), accountUUID).Return([]accountmanagement.UsersDto{}, nil)
462-
// Once temporary featureflags.ServiceUsers is removed, uncomment the following:
463-
//client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
478+
// Once temporary featureflags.ServiceUsers is removed, remove the following:
479+
if featureflags.ServiceUsers.Enabled() {
480+
client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
481+
}
464482

465483
result, err := downloader.DownloadResources(t.Context())
466484
assert.NoError(t, err)
@@ -610,8 +628,10 @@ func TestDownloader_GroupsWithPermissions(t *testing.T) {
610628
client.EXPECT().GetPolicyGroupBindings(gomock.Any(), "environment", "abc12345").Return(&accountmanagement.LevelPolicyBindingDto{}, nil)
611629

612630
client.EXPECT().GetUsers(gomock.Any(), accountUUID).Return([]accountmanagement.UsersDto{}, nil)
613-
// Once temporary featureflags.ServiceUsers is removed, uncomment the following:
614-
//client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
631+
// Once temporary featureflags.ServiceUsers is removed, remove the following:
632+
if featureflags.ServiceUsers.Enabled() {
633+
client.EXPECT().GetServiceUsers(gomock.Any(), accountUUID).Return([]accountmanagement.ExternalServiceUserDto{}, nil)
634+
}
615635

616636
result, err := downloader.DownloadResources(t.Context())
617637
assert.NoError(t, err)

0 commit comments

Comments
 (0)