IAM: Create Service Account API and legacy store impl (#110411)
* wip * IAM: Create Service Account * Add dual writer * Update openapi_test.go * Add integration tests * Add sql tests * Add Role to SA spec, add validation, add DBTime, add tests * Format, update test * Fixes * Add check for External * Address feedback * Update tests * Address feedback * make gen-go * Simplify a bit * Fixes * make update-workspace * Update pkg/registry/apis/iam/serviceaccount/store.go Co-authored-by: Ryan McKinley <ryantxu@gmail.com> * Address feedback, add test for generateName --------- Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
@@ -88,6 +88,12 @@ func TestIdentityQueries(t *testing.T) {
|
||||
return &v
|
||||
}
|
||||
|
||||
createServiceAccounts := func(cmd *CreateServiceAccountCommand) sqltemplate.SQLTemplate {
|
||||
v := newCreateServiceAccount(nodb, cmd)
|
||||
v.SQLTemplate = mocks.NewTestingSQLTemplate()
|
||||
return &v
|
||||
}
|
||||
|
||||
listServiceAccountTokens := func(q *ListServiceAccountTokenQuery) sqltemplate.SQLTemplate {
|
||||
v := newListServiceAccountTokens(nodb, q)
|
||||
v.SQLTemplate = mocks.NewTestingSQLTemplate()
|
||||
@@ -361,8 +367,8 @@ func TestIdentityQueries(t *testing.T) {
|
||||
OrgID: 1,
|
||||
UserID: 123,
|
||||
Role: "Viewer",
|
||||
Created: time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
Updated: time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
Created: NewDBTime(time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)),
|
||||
Updated: NewDBTime(time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)),
|
||||
}),
|
||||
},
|
||||
{
|
||||
@@ -371,8 +377,8 @@ func TestIdentityQueries(t *testing.T) {
|
||||
OrgID: 2,
|
||||
UserID: 456,
|
||||
Role: "Admin",
|
||||
Created: time.Date(2023, 2, 1, 10, 30, 0, 0, time.UTC),
|
||||
Updated: time.Date(2023, 2, 1, 10, 30, 0, 0, time.UTC),
|
||||
Created: NewDBTime(time.Date(2023, 2, 1, 10, 30, 0, 0, time.UTC)),
|
||||
Updated: NewDBTime(time.Date(2023, 2, 1, 10, 30, 0, 0, time.UTC)),
|
||||
}),
|
||||
},
|
||||
},
|
||||
@@ -391,9 +397,9 @@ func TestIdentityQueries(t *testing.T) {
|
||||
IsProvisioned: false,
|
||||
Salt: "randomsalt",
|
||||
Rands: "randomrands",
|
||||
Created: time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
Updated: time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
LastSeenAt: time.Date(2013, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
Created: NewDBTime(time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)),
|
||||
Updated: NewDBTime(time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)),
|
||||
LastSeenAt: NewDBTime(time.Date(2013, 1, 1, 12, 0, 0, 0, time.UTC)),
|
||||
Role: "Viewer",
|
||||
}),
|
||||
},
|
||||
@@ -411,13 +417,43 @@ func TestIdentityQueries(t *testing.T) {
|
||||
IsProvisioned: true,
|
||||
Salt: "adminsalt",
|
||||
Rands: "adminrands",
|
||||
Created: time.Date(2023, 2, 1, 10, 30, 0, 0, time.UTC),
|
||||
Updated: time.Date(2023, 2, 1, 10, 30, 0, 0, time.UTC),
|
||||
LastSeenAt: time.Date(2013, 2, 1, 10, 30, 0, 0, time.UTC),
|
||||
Created: NewDBTime(time.Date(2023, 2, 1, 10, 30, 0, 0, time.UTC)),
|
||||
Updated: NewDBTime(time.Date(2023, 2, 1, 10, 30, 0, 0, time.UTC)),
|
||||
LastSeenAt: NewDBTime(time.Date(2013, 2, 1, 10, 30, 0, 0, time.UTC)),
|
||||
Role: "Admin",
|
||||
}),
|
||||
},
|
||||
},
|
||||
sqlCreateServiceAccountTemplate: {
|
||||
{
|
||||
Name: "create_service_account_basic",
|
||||
Data: createServiceAccounts(&CreateServiceAccountCommand{
|
||||
UID: "abcdef",
|
||||
Name: "Service Account 1",
|
||||
Email: "sa-1-service-account-1",
|
||||
Login: "sa-1-service-account-1",
|
||||
IsDisabled: false,
|
||||
OrgID: 1,
|
||||
Created: NewDBTime(time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)),
|
||||
Updated: NewDBTime(time.Date(2023, 1, 1, 12, 0, 0, 0, time.UTC)),
|
||||
LastSeenAt: time.Date(2013, 1, 1, 12, 0, 0, 0, time.UTC),
|
||||
}),
|
||||
},
|
||||
{
|
||||
Name: "create_service_account_disabled",
|
||||
Data: createServiceAccounts(&CreateServiceAccountCommand{
|
||||
UID: "abcdef",
|
||||
Name: "Disabled Service Account",
|
||||
Email: "sa-2-disabled-service-account",
|
||||
Login: "sa-2-disabled-service-account",
|
||||
IsDisabled: true,
|
||||
OrgID: 2,
|
||||
Created: NewDBTime(time.Date(2023, 2, 1, 10, 30, 0, 0, time.UTC)),
|
||||
Updated: NewDBTime(time.Date(2023, 2, 1, 10, 30, 0, 0, time.UTC)),
|
||||
LastSeenAt: time.Date(2013, 2, 1, 10, 30, 0, 0, time.UTC),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user