Skip to content

Commit c93a707

Browse files
authored
CLOUDP-271909: fix deleted user struct (#240)
1 parent 221d95e commit c93a707

26 files changed

+49
-43
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: lint
2020
uses: golangci/golangci-lint-action@v6.1.0
2121
with:
22-
version: v1.54.2
22+
version: v1.60
2323

2424
tests-on-unix:
2525
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors

atmcfg/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package atmcfg
1616

1717
import (
18-
"crypto/sha1" //nolint:gosec // mongodb scram-sha-1 supports this tho is not recommended
18+
"crypto/sha1" // #nosec G101 // #nosec G505 // mongodb scram-sha-1 supports this tho is not recommended
1919
"crypto/sha256"
2020
"encoding/base64"
2121
"errors"

atmcfg/security.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package atmcfg
1616

1717
import (
1818
"crypto/hmac"
19-
"crypto/md5" //nolint:gosec // used as part of the sha1 standard
19+
"crypto/md5" // #nosec G101 // #nosec G501 // used as part of the sha1 standard
2020
"encoding/base64"
2121
"encoding/hex"
2222
"fmt"
@@ -165,7 +165,7 @@ func generateSalt(hashConstructor func() hash.Hash) ([]byte, error) {
165165
}
166166

167167
func md5Hex(s string) (string, error) {
168-
h := md5.New() //nolint:gosec // used as part of the sha1 standard
168+
h := md5.New() // #nosec G101 // #nosec G401 // used as part of the sha1 standard
169169

170170
if _, err := h.Write([]byte(s)); err != nil {
171171
return "", err

atmcfg/security_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package atmcfg
1616

1717
import (
18-
"crypto/sha1" //nolint:gosec // used as part of the sha1 standard
18+
"crypto/sha1" // #nosec G101 // #nosec G505 // used as part of the sha1 standard
1919
"testing"
2020

2121
"github.com/stretchr/testify/assert"

auth/device_flow_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func TestConfig_RevokeToken(t *testing.T) {
173173
config, mux, teardown := setup()
174174
defer teardown()
175175

176-
mux.HandleFunc("/api/private/unauth/account/device/revoke", func(w http.ResponseWriter, r *http.Request) {
176+
mux.HandleFunc("/api/private/unauth/account/device/revoke", func(_ http.ResponseWriter, r *http.Request) {
177177
testMethod(t, r)
178178
})
179179

opsmngr/accesslist_api_keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"net/http"
2121
)
2222

23-
const accessListAPIKeysPath = "api/public/v1.0/orgs/%s/apiKeys/%s/accessList" //nolint:gosec // This is a path
23+
const accessListAPIKeysPath = "api/public/v1.0/orgs/%s/apiKeys/%s/accessList" // #nosec G101 // This is a path
2424

2525
// AccessListAPIKeysService is an interface for interfacing with the AccessList API Keys
2626
// endpoints of the MongoDB Ops Manager API.

opsmngr/accesslist_api_keys_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
const (
27-
apiKeyID = "API-KEY-ID" //nolint:gosec // ID and not an actual key
27+
apiKeyID = "API-KEY-ID" // #nosec G101 // ID and not an actual key
2828
ipAddress = "IP-ADDRESS"
2929
)
3030

opsmngr/agents_api_keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
const (
24-
agentAPIKeysBasePath = "api/public/v1.0/groups/%s/agentapikeys" //nolint:gosec // This is a path
24+
agentAPIKeysBasePath = "api/public/v1.0/groups/%s/agentapikeys" // #nosec G101 // This is a path
2525
)
2626

2727
// AgentAPIKey defines the structure for an Agent API key.

opsmngr/agents_api_keys_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/go-test/deep"
2323
)
2424

25-
const projectID = "5e66185d917b220fbd8bb4d1" //nolint:gosec // not a credential
25+
const projectID = "5e66185d917b220fbd8bb4d1" // not a credential
2626

2727
func TestAgentsServiceOp_ListAgentAPIKeys(t *testing.T) {
2828
client, mux, teardown := setup()

opsmngr/alert_configurations_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/go-test/deep"
2424
)
2525

26-
const alertConfigID = "57b76ddc96e8215c017ceafb" //nolint:gosec // not a credential
26+
const alertConfigID = "57b76ddc96e8215c017ceafb" // #nosec G101 // not a credential
2727

2828
func TestAlertConfiguration_Create(t *testing.T) {
2929
client, mux, teardown := setup()

opsmngr/alerts_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/go-test/deep"
2323
)
2424

25-
const alertID = "57b76ddc96e8215c017ceafb" //nolint:gosec // not a credential
25+
const alertID = "57b76ddc96e8215c017ceafb" // #nosec G101 // not a credential
2626

2727
func TestAlert_Get(t *testing.T) {
2828
client, mux, teardown := setup()

opsmngr/automation_config.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,22 @@ type SSL struct {
183183
//
184184
// See: https://docs.opsmanager.mongodb.com/current/reference/api/automation-config/automation-config-parameters/#authentication
185185
type Auth struct {
186-
AuthoritativeSet bool `json:"authoritativeSet"` // AuthoritativeSet indicates if the MongoDBUsers should be synced with the current list of UsersWanted
187-
AutoAuthMechanism string `json:"autoAuthMechanism"` // AutoAuthMechanism is the currently active agent authentication mechanism. This is a read only field
188-
AutoAuthMechanisms []string `json:"autoAuthMechanisms,omitempty"` // AutoAuthMechanisms is a list of auth mechanisms the Automation Agent is able to use
189-
AutoAuthRestrictions []interface{} `json:"autoAuthRestrictions"`
190-
AutoKerberosKeytabPath string `json:"autoKerberosKeytabPath,omitempty"`
191-
AutoLdapGroupDN string `json:"autoLdapGroupDN,omitempty"` //nolint:tagliatelle // AutoLdapGroupDN follows go convention while tag is correct from API
192-
AutoPwd string `json:"autoPwd,omitempty"` // AutoPwd is a required field when going from `Disabled=false` to `Disabled=true`
193-
AutoUser string `json:"autoUser,omitempty"` // AutoUser is the MongoDB Automation Agent user, when x509 is enabled, it should be set to the subject of the AA's certificate
194-
DeploymentAuthMechanisms []string `json:"deploymentAuthMechanisms,omitempty"` // DeploymentAuthMechanisms is a list of possible auth mechanisms that can be used within deployments
195-
Disabled bool `json:"disabled"` // Disabled indicates if auth is disabled
196-
Key string `json:"key,omitempty"` // Key is the contents of the Keyfile, the automation agent will ensure this a Keyfile with these contents exists at the `Keyfile` path
197-
Keyfile string `json:"keyfile,omitempty"` // Keyfile is the path to a keyfile with read & write permissions. It is a required field if `Disabled=false`
198-
KeyfileWindows string `json:"keyfileWindows,omitempty"` // KeyfileWindows is required if `Disabled=false` even if the value is not used.
199-
NewAutoPwd string `json:"newAutoPwd,omitempty"` // NewAutoPwd is a new password that the Automation uses when connecting to an instance.
200-
UsersDeleted []*MongoDBUser `json:"usersDeleted"` // UsersDeleted are objects that define the authenticated users to be deleted from specified databases or from all databases
201-
UsersWanted []*MongoDBUser `json:"usersWanted"` // UsersWanted is a list which contains the desired users at the project level.
186+
AuthoritativeSet bool `json:"authoritativeSet"` // AuthoritativeSet indicates if the MongoDBUsers should be synced with the current list of UsersWanted
187+
AutoAuthMechanism string `json:"autoAuthMechanism"` // AutoAuthMechanism is the currently active agent authentication mechanism. This is a read only field
188+
AutoAuthMechanisms []string `json:"autoAuthMechanisms,omitempty"` // AutoAuthMechanisms is a list of auth mechanisms the Automation Agent is able to use
189+
AutoAuthRestrictions []interface{} `json:"autoAuthRestrictions"`
190+
AutoKerberosKeytabPath string `json:"autoKerberosKeytabPath,omitempty"`
191+
AutoLdapGroupDN string `json:"autoLdapGroupDN,omitempty"` //nolint:tagliatelle // AutoLdapGroupDN follows go convention while tag is correct from API
192+
AutoPwd string `json:"autoPwd,omitempty"` // AutoPwd is a required field when going from `Disabled=false` to `Disabled=true`
193+
AutoUser string `json:"autoUser,omitempty"` // AutoUser is the MongoDB Automation Agent user, when x509 is enabled, it should be set to the subject of the AA's certificate
194+
DeploymentAuthMechanisms []string `json:"deploymentAuthMechanisms,omitempty"` // DeploymentAuthMechanisms is a list of possible auth mechanisms that can be used within deployments
195+
Disabled bool `json:"disabled"` // Disabled indicates if auth is disabled
196+
Key string `json:"key,omitempty"` // Key is the contents of the Keyfile, the automation agent will ensure this a Keyfile with these contents exists at the `Keyfile` path
197+
Keyfile string `json:"keyfile,omitempty"` // Keyfile is the path to a keyfile with read & write permissions. It is a required field if `Disabled=false`
198+
KeyfileWindows string `json:"keyfileWindows,omitempty"` // KeyfileWindows is required if `Disabled=false` even if the value is not used.
199+
NewAutoPwd string `json:"newAutoPwd,omitempty"` // NewAutoPwd is a new password that the Automation uses when connecting to an instance.
200+
UsersDeleted []*MongoDBDeletedUser `json:"usersDeleted"` // UsersDeleted are objects that define the authenticated users to be deleted from specified databases or from all databases
201+
UsersWanted []*MongoDBUser `json:"usersWanted"` // UsersWanted is a list which contains the desired users at the project level.
202202
}
203203

204204
// Args26 part of the internal Process struct.
@@ -231,6 +231,12 @@ type MongoDBUser struct {
231231
Username string `json:"user"` //nolint:tagliatelle // Username is a better name than just user
232232
}
233233

234+
// MongoDBDeletedUser user to delete from DBs list.
235+
type MongoDBDeletedUser struct {
236+
User string `json:"user"`
237+
DBs []string `json:"dbs"` //nolint:tagliatelle // use dbs as in the API
238+
}
239+
234240
// AuthenticationRestriction of a database user.
235241
type AuthenticationRestriction struct {
236242
ClientSource []string `json:"clientSource"`

opsmngr/checkpoints_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/go-test/deep"
2323
)
2424

25-
const clusterID = "6b8cd61180eef547110159d9" //nolint:gosec // not a credential
25+
const clusterID = "6b8cd61180eef547110159d9" // #nosec G101 // not a credential
2626

2727
func TestCheckpoints_List(t *testing.T) {
2828
client, mux, teardown := setup()
@@ -263,7 +263,7 @@ func TestCheckpoints_Get(t *testing.T) {
263263
client, mux, teardown := setup()
264264
defer teardown()
265265

266-
const checkpointID = "6b8cd61180eef547110159d9" //nolint:gosec // not a credential
266+
const checkpointID = "6b8cd61180eef547110159d9" // #nosec G101 // not a credential
267267
path := fmt.Sprintf("/api/public/v1.0/groups/%s/clusters/%s/checkpoints/%s", projectID, clusterID, checkpointID)
268268

269269
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {

opsmngr/continuous_snapshots_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525

2626
const (
2727
clusterName = "Cluster0"
28-
snapshotID = "6b5380e6jvn128560506942b" //nolint:gosec // not a credential
28+
snapshotID = "6b5380e6jvn128560506942b" // #nosec G101 // not a credential
2929
)
3030

3131
func TestContinuousSnapshots_List(t *testing.T) {

opsmngr/events_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/go-test/deep"
2323
)
2424

25-
const eventID = "b3ad04e680eef540be141abe" //nolint:gosec // not a credential
25+
const eventID = "b3ad04e680eef540be141abe" // #nosec G101 // not a credential
2626

2727
func TestEvents_ListOrganizationEvents(t *testing.T) {
2828
client, mux, teardown := setup()

opsmngr/global_api_key_whitelists.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"net/http"
2121
)
2222

23-
const whitelistAPIKeysPath = "api/public/v1.0/admin/whitelist" //nolint:gosec // This is a path
23+
const whitelistAPIKeysPath = "api/public/v1.0/admin/whitelist" // #nosec G101 // This is a path
2424

2525
// GlobalAPIKeyWhitelistsService provides access to the global alerts related functions in the Ops Manager API.
2626
//

opsmngr/global_api_key_whitelists_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/go-test/deep"
2424
)
2525

26-
const accessListID = "5f3cf81b89034c6b3c0a528e" //nolint:gosec // not a credential
26+
const accessListID = "5f3cf81b89034c6b3c0a528e" // #nosec G101 // not a credential
2727

2828
func TestWhitelistAPIKeys_List(t *testing.T) {
2929
client, mux, teardown := setup()

opsmngr/global_api_keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"net/url"
2222
)
2323

24-
const apiKeysPath = "api/public/v1.0/admin/apiKeys" //nolint:gosec // This is a path
24+
const apiKeysPath = "api/public/v1.0/admin/apiKeys" // #nosec G101 // This is a path
2525

2626
// GlobalAPIKeysService provides access to the global alerts related functions in the Ops Manager API.
2727
//

opsmngr/global_api_keys_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const (
2727
apiDesc = "test-apikeye"
2828
ewmaqvdo = "ewmaqvdo"
2929
testAPIKey = "test-apikey"
30-
globalAPIKeyID = "5c47503320eef5699e1cce8d" //nolint:gosec // ID and not an actual key
30+
globalAPIKeyID = "5c47503320eef5699e1cce8d" // #nosec G101 // ID and not an actual key
3131
)
3232

3333
func TestAPIKeys_ListAPIKeys(t *testing.T) {

opsmngr/maintenance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/go-test/deep"
2323
)
2424

25-
const ID = "5628faffd4c606594adaa3b2" //nolint:gosec // not a credential
25+
const ID = "5628faffd4c606594adaa3b2" // #nosec G101 // not a credential
2626

2727
func TestMaintenanceWindows_List(t *testing.T) {
2828
client, mux, teardown := setup()

opsmngr/organization_api_keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"net/url"
2222
)
2323

24-
const apiKeysOrgPath = "api/public/v1.0/orgs/%s/apiKeys" //nolint:gosec // This is a path
24+
const apiKeysOrgPath = "api/public/v1.0/orgs/%s/apiKeys" // #nosec G101 // This is a path
2525

2626
// APIKeysService is an interface for interfacing with the APIKeys.
2727
type APIKeysService interface {

opsmngr/organizations_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/go-test/deep"
2323
)
2424

25-
const orgID = "5a0a1e7e0f2912c554081adc" //nolint:gosec // not a credential
25+
const orgID = "5a0a1e7e0f2912c554081adc" // #nosec G101 // not a credential
2626

2727
func TestOrganizations_GetAllOrganizations(t *testing.T) {
2828
client, mux, teardown := setup()

opsmngr/project_api_keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"net/http"
2121
)
2222

23-
const projectAPIKeysPath = "api/public/v1.0/groups/%s/apiKeys" //nolint:gosec // This is a path
23+
const projectAPIKeysPath = "api/public/v1.0/groups/%s/apiKeys" // #nosec G101 // This is a path
2424

2525
// ProjectAPIKeysService is an interface for interfacing with the APIKeys.
2626
type ProjectAPIKeysService interface {

opsmngr/teams_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/go-test/deep"
2424
)
2525

26-
const teamID = "6b720e1087d9d66b272f1c86" //nolint:gosec // not a credential
26+
const teamID = "6b720e1087d9d66b272f1c86" // #nosec G101 // not a credential
2727

2828
func TestTeams_List(t *testing.T) {
2929
client, mux, teardown := setup()

opsmngr/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type User struct {
4949
Links []*Link `json:"links,omitempty"`
5050
MobileNumber string `json:"mobileNumber,omitempty"`
5151
Password string `json:"password,omitempty"`
52-
TeamIds []string `json:"teamIds,omitempty"`
52+
TeamIds []string `json:"teamIds,omitempty"` //nolint:all // used as in the API
5353
Roles []*UserRole `json:"roles,omitempty"`
5454
Username string `json:"username"`
5555
Country string `json:"country,omitempty"`

opsmngr/users_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/go-test/deep"
2323
)
2424

25-
const userID = "56a10a80e4b0fd3b9a9bb0c2" //nolint:gosec // not a credential
25+
const userID = "56a10a80e4b0fd3b9a9bb0c2" // #nosec G101 // not a credential
2626
const userName = "someone@example.com"
2727

2828
func TestUsers_Get(t *testing.T) {

0 commit comments

Comments
 (0)