Skip to content

Commit b2cc747

Browse files
authored
CLOUDP-246401: Add dbusers e2e test as we have IDPs now (#2913)
1 parent 638266f commit b2cc747

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

build/ci/evergreen.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ functions:
8484
- E2E_TIMEOUT
8585
- E2E_SERVERLESS_INSTANCE_NAME
8686
- E2E_PARALLEL
87+
- IDENTITY_PROVIDER_ID
8788
- revision
8889
env:
8990
<<: *go_env
@@ -218,6 +219,7 @@ tasks:
218219
MCLI_OPS_MANAGER_URL: ${mcli_ops_manager_url}
219220
MCLI_SERVICE: cloud
220221
E2E_TAGS: atlas,generic
222+
IDENTITY_PROVIDER_ID: ${identity_provider_id}
221223
- name: atlas_gov_generic_e2e
222224
tags: ["e2e","generic","atlas"]
223225
must_have_test_results: true
@@ -236,6 +238,7 @@ tasks:
236238
MCLI_OPS_MANAGER_URL: ${mcli_cloud_gov_ops_manager_url}
237239
MCLI_SERVICE: cloudgov
238240
E2E_TAGS: atlas,generic
241+
IDENTITY_PROVIDER_ID: ${identity_provider_id}
239242
# This is all about cluster which tends to be slow to get a healthy one
240243
- name: atlas_clusters_flags_e2e
241244
tags: ["e2e","clusters","atlas"]

docs/command/atlas-dbusers-create.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ atlas dbusers create
1414

1515
Create a database user for your project.
1616

17-
If you set --ldapType, --x509Type, and --awsIAMType to NONE, Atlas authenticates this user through SCRAM-SHA. To learn more, see https://www.mongodb.com/docs/manual/core/security-scram/.
17+
If you set --ldapType, --x509Type, --oidcType and --awsIAMType to NONE, Atlas authenticates this user through SCRAM-SHA. To learn more, see https://www.mongodb.com/docs/manual/core/security-scram/.
1818

1919
To use this command, you must authenticate with a user account or an API key with the Project Owner role.
2020

internal/cli/dbusers/create.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (opts *CreateOpts) isOIDCSet() bool {
8383
}
8484

8585
func (opts *CreateOpts) isExternal() bool {
86-
return opts.isX509Set() || opts.isAWSIAMSet() || opts.isLDAPSet() || opts.isOIDCSet()
86+
return opts.isX509Set() || opts.isAWSIAMSet() || opts.isLDAPSet()
8787
}
8888

8989
func (opts *CreateOpts) initStore(ctx context.Context) func() error {
@@ -144,7 +144,7 @@ func (opts *CreateOpts) newDatabaseUser() *atlasv2.CloudDatabaseUser {
144144
}
145145

146146
func (opts *CreateOpts) Prompt() error {
147-
if opts.isExternal() || opts.password != "" {
147+
if opts.isExternal() || opts.isOIDCSet() || opts.password != "" {
148148
return nil
149149
}
150150

@@ -197,7 +197,7 @@ func CreateBuilder() *cobra.Command {
197197
cmd := &cobra.Command{
198198
Use: "create [builtInRole]...",
199199
Short: "Create a database user for your project.",
200-
Long: `If you set --ldapType, --x509Type, and --awsIAMType to NONE, Atlas authenticates this user through SCRAM-SHA. To learn more, see https://www.mongodb.com/docs/manual/core/security-scram/.
200+
Long: `If you set --ldapType, --x509Type, --oidcType and --awsIAMType to NONE, Atlas authenticates this user through SCRAM-SHA. To learn more, see https://www.mongodb.com/docs/manual/core/security-scram/.
201201
202202
` + fmt.Sprintf(usage.RequiredRole, "Project Owner"),
203203
Example: ` # Create an Atlas database admin user named myAdmin for the project with ID 5e2211c17a3e5a48f5497de3:

test/e2e/atlas/dbusers_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ func TestDBUsersWithStdin(t *testing.T) {
133133
t.Fatalf("unexpected error: %v", err)
134134
}
135135

136+
idpID, _ := os.LookupEnv("IDENTITY_PROVIDER_ID")
137+
require.NotEmpty(t, idpID)
138+
oidcUsername := idpID + "/" + username
139+
136140
cliPath, err := e2e.AtlasCLIBin()
137141
if err != nil {
138142
t.Fatalf("unexpected error: %v", err)
@@ -156,8 +160,24 @@ func TestDBUsersWithStdin(t *testing.T) {
156160
testCreateUserCmd(t, cmd, username)
157161
})
158162

163+
t.Run("Create OIDC user", func(t *testing.T) {
164+
cmd := exec.Command(cliPath,
165+
dbusersEntity,
166+
"create",
167+
"atlasAdmin",
168+
"--username", oidcUsername,
169+
"--oidcType",
170+
"IDP_GROUP",
171+
"--scope", scopeClusterDataLake,
172+
"-o=json",
173+
)
174+
175+
testCreateUserCmd(t, cmd, oidcUsername)
176+
})
177+
159178
t.Run("Describe", func(t *testing.T) {
160179
testDescribeUser(t, cliPath, username)
180+
testDescribeUser(t, cliPath, oidcUsername)
161181
})
162182

163183
t.Run("Update", func(t *testing.T) {
@@ -176,6 +196,7 @@ func TestDBUsersWithStdin(t *testing.T) {
176196

177197
t.Run("Delete", func(t *testing.T) {
178198
testDeleteUser(t, cliPath, dbusersEntity, username)
199+
testDeleteUser(t, cliPath, dbusersEntity, oidcUsername)
179200
})
180201
}
181202

0 commit comments

Comments
 (0)