Skip to content

Commit dc53924

Browse files
coderGo93Edgar López
andauthored
deleted omitempty for scopes of database users (#162)
Co-authored-by: Edgar López <edgarlopez@pop-os.localdomain>
1 parent 85a3c4d commit dc53924

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

mongodbatlas/database_users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type DatabaseUser struct {
5353
AWSIAMType string `json:"awsIAMType,omitempty"`
5454
GroupID string `json:"groupId,omitempty"`
5555
Roles []Role `json:"roles,omitempty"`
56-
Scopes []Scope `json:"scopes,omitempty"`
56+
Scopes []Scope `json:"scopes"`
5757
Password string `json:"password,omitempty"`
5858
Username string `json:"username,omitempty"`
5959
}

mongodbatlas/database_users_test.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ func TestDatabaseUsers_CreateWithX509Type(t *testing.T) {
154154
DatabaseName: "admin",
155155
RoleName: "readWriteAnyDatabase",
156156
}},
157+
Scopes: []Scope{},
157158
}
158159

159160
mux.HandleFunc(fmt.Sprintf("/groups/%s/databaseUsers", groupID), func(w http.ResponseWriter, r *http.Request) {
@@ -167,6 +168,7 @@ func TestDatabaseUsers_CreateWithX509Type(t *testing.T) {
167168
"databaseName": "admin",
168169
"roleName": "readWriteAnyDatabase",
169170
}},
171+
"scopes": []interface{}{},
170172
}
171173

172174
var v map[string]interface{}
@@ -189,7 +191,8 @@ func TestDatabaseUsers_CreateWithX509Type(t *testing.T) {
189191
"databaseName": "admin",
190192
"roleName": "readWriteAnyDatabase"
191193
}
192-
]
194+
],
195+
"scopes" : []
193196
}`)
194197
})
195198

@@ -220,6 +223,7 @@ func TestDatabaseUsers_CreateWithAWSIAMType(t *testing.T) {
220223
DatabaseName: "admin",
221224
RoleName: "readWriteAnyDatabase",
222225
}},
226+
Scopes: []Scope{},
223227
}
224228

225229
mux.HandleFunc(fmt.Sprintf("/groups/%s/databaseUsers", groupID), func(w http.ResponseWriter, r *http.Request) {
@@ -233,6 +237,7 @@ func TestDatabaseUsers_CreateWithAWSIAMType(t *testing.T) {
233237
"databaseName": "admin",
234238
"roleName": "readWriteAnyDatabase",
235239
}},
240+
"scopes": []interface{}{},
236241
}
237242

238243
var v map[string]interface{}
@@ -255,7 +260,8 @@ func TestDatabaseUsers_CreateWithAWSIAMType(t *testing.T) {
255260
"databaseName": "admin",
256261
"roleName": "readWriteAnyDatabase"
257262
}
258-
]
263+
],
264+
"scopes" : []
259265
}`)
260266
})
261267

@@ -287,6 +293,7 @@ func TestDatabaseUsers_Create(t *testing.T) {
287293
CollectionName: "test-collection-name",
288294
RoleName: "test-role-name",
289295
}},
296+
Scopes: []Scope{},
290297
}
291298

292299
mux.HandleFunc(fmt.Sprintf("/groups/%s/databaseUsers", groupID), func(w http.ResponseWriter, r *http.Request) {
@@ -300,6 +307,7 @@ func TestDatabaseUsers_Create(t *testing.T) {
300307
"collectionName": "test-collection-name",
301308
"roleName": "test-role-name",
302309
}},
310+
"scopes": []interface{}{},
303311
}
304312

305313
jsonBlob := `
@@ -314,7 +322,8 @@ func TestDatabaseUsers_Create(t *testing.T) {
314322
"collectionName": "test-collection-name",
315323
"roleName": "test-role-name"
316324
}
317-
]
325+
],
326+
"scopes": []
318327
}
319328
`
320329

@@ -471,6 +480,7 @@ func TestDatabaseUsers_Update(t *testing.T) {
471480
CollectionName: "test-collection-name",
472481
RoleName: "test-role-name",
473482
}},
483+
Scopes: []Scope{},
474484
}
475485

476486
mux.HandleFunc(fmt.Sprintf("/groups/%s/databaseUsers/admin/%s", groupID, "test-username"), func(w http.ResponseWriter, r *http.Request) {
@@ -484,6 +494,7 @@ func TestDatabaseUsers_Update(t *testing.T) {
484494
"collectionName": "test-collection-name",
485495
"roleName": "test-role-name",
486496
}},
497+
"scopes": []interface{}{},
487498
}
488499

489500
jsonBlob := `
@@ -498,7 +509,8 @@ func TestDatabaseUsers_Update(t *testing.T) {
498509
"collectionName": "test-collection-name",
499510
"roleName": "test-role-name"
500511
}
501-
]
512+
],
513+
"scopes" : []
502514
}
503515
`
504516

0 commit comments

Comments
 (0)