Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
henvic committed Dec 19, 2023
1 parent 6624561 commit 13c9018
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
14 changes: 6 additions & 8 deletions integration/users/create_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestCreateUser(t *testing.T) {
} else {
// Erase any previously saved user in the database.
_, err := users.DeleteMany(ctx, bson.D{{"db", db.Name()}})
assert.NoError(t, err)
require.NoError(t, err)
}

testCases := map[string]struct { //nolint:vet // for readability
Expand Down Expand Up @@ -87,9 +87,7 @@ func TestCreateUser(t *testing.T) {
{"pwd", "password"},
},
expected: bson.D{
{
"ok", float64(1),
},
{"ok", float64(1)},
},
},
"WithComment": {
Expand All @@ -100,9 +98,7 @@ func TestCreateUser(t *testing.T) {
{"comment", "test string comment"},
},
expected: bson.D{
{
"ok", float64(1),
},
{"ok", float64(1)},
},
},
"MissingRoles": {
Expand All @@ -118,12 +114,14 @@ func TestCreateUser(t *testing.T) {
},
}

// The subtest "AlreadyExists" tries to create the following user, which should fail with an error that the user already exists.
// Here, we create the user for the very first time to populate the database.
err := db.RunCommand(ctx, bson.D{
{"createUser", "should_already_exist"},
{"roles", bson.A{}},
{"pwd", "password"},
}).Err()
assert.NoError(t, err)
require.NoError(t, err)

for name, tc := range testCases {
name, tc := name, tc
Expand Down
1 change: 0 additions & 1 deletion internal/handler/msg_createuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func (h *Handler) MsgCreateUser(ctx context.Context, msg *wire.OpMsg) (*wire.OpM
return nil, err
}

// NOTE: In MongoDB, the comment field isn't saved in the database, but used for log and profiling.
common.Ignored(document, h.L, "pwd", "writeConcern", "authenticationRestrictions", "mechanisms", "comment")

id := uuid.New()
Expand Down
1 change: 0 additions & 1 deletion internal/handler/msg_dropuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func (h *Handler) MsgDropUser(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg
return nil, lazyerrors.Error(err)
}

// NOTE: In MongoDB, the comment field isn't saved in the database, but used for log and profiling.
common.Ignored(document, h.L, "writeConcern", "comment")

dbName, err := common.GetRequiredParam[string](document, "$db")
Expand Down

0 comments on commit 13c9018

Please sign in to comment.