Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOUDP-271909: fix deleted user struct #240

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: lint
uses: golangci/[email protected]
with:
version: v1.54.2
version: v1.60
gssbzn marked this conversation as resolved.
Show resolved Hide resolved

tests-on-unix:
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
Expand Down
2 changes: 1 addition & 1 deletion atmcfg/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package atmcfg

import (
"crypto/sha1" //nolint:gosec // mongodb scram-sha-1 supports this tho is not recommended
"crypto/sha1" // #nosec G101 // #nosec G505 // mongodb scram-sha-1 supports this tho is not recommended
"crypto/sha256"
"encoding/base64"
"errors"
Expand Down
4 changes: 2 additions & 2 deletions atmcfg/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package atmcfg

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

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

if _, err := h.Write([]byte(s)); err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion atmcfg/security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package atmcfg

import (
"crypto/sha1" //nolint:gosec // used as part of the sha1 standard
"crypto/sha1" // #nosec G101 // #nosec G505 // used as part of the sha1 standard
"testing"

"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion auth/device_flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestConfig_RevokeToken(t *testing.T) {
config, mux, teardown := setup()
defer teardown()

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

Expand Down
2 changes: 1 addition & 1 deletion opsmngr/accesslist_api_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net/http"
)

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

// AccessListAPIKeysService is an interface for interfacing with the AccessList API Keys
// endpoints of the MongoDB Ops Manager API.
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/accesslist_api_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

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

Expand Down
2 changes: 1 addition & 1 deletion opsmngr/agents_api_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

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

// AgentAPIKey defines the structure for an Agent API key.
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/agents_api_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/go-test/deep"
)

const projectID = "5e66185d917b220fbd8bb4d1" //nolint:gosec // not a credential
const projectID = "5e66185d917b220fbd8bb4d1" // not a credential

func TestAgentsServiceOp_ListAgentAPIKeys(t *testing.T) {
client, mux, teardown := setup()
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/alert_configurations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/go-test/deep"
)

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

func TestAlertConfiguration_Create(t *testing.T) {
client, mux, teardown := setup()
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/alerts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/go-test/deep"
)

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

func TestAlert_Get(t *testing.T) {
client, mux, teardown := setup()
Expand Down
38 changes: 22 additions & 16 deletions opsmngr/automation_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,22 @@ type SSL struct {
//
// See: https://docs.opsmanager.mongodb.com/current/reference/api/automation-config/automation-config-parameters/#authentication
type Auth struct {
AuthoritativeSet bool `json:"authoritativeSet"` // AuthoritativeSet indicates if the MongoDBUsers should be synced with the current list of UsersWanted
AutoAuthMechanism string `json:"autoAuthMechanism"` // AutoAuthMechanism is the currently active agent authentication mechanism. This is a read only field
AutoAuthMechanisms []string `json:"autoAuthMechanisms,omitempty"` // AutoAuthMechanisms is a list of auth mechanisms the Automation Agent is able to use
AutoAuthRestrictions []interface{} `json:"autoAuthRestrictions"`
AutoKerberosKeytabPath string `json:"autoKerberosKeytabPath,omitempty"`
AutoLdapGroupDN string `json:"autoLdapGroupDN,omitempty"` //nolint:tagliatelle // AutoLdapGroupDN follows go convention while tag is correct from API
AutoPwd string `json:"autoPwd,omitempty"` // AutoPwd is a required field when going from `Disabled=false` to `Disabled=true`
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
DeploymentAuthMechanisms []string `json:"deploymentAuthMechanisms,omitempty"` // DeploymentAuthMechanisms is a list of possible auth mechanisms that can be used within deployments
Disabled bool `json:"disabled"` // Disabled indicates if auth is disabled
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
Keyfile string `json:"keyfile,omitempty"` // Keyfile is the path to a keyfile with read & write permissions. It is a required field if `Disabled=false`
KeyfileWindows string `json:"keyfileWindows,omitempty"` // KeyfileWindows is required if `Disabled=false` even if the value is not used.
NewAutoPwd string `json:"newAutoPwd,omitempty"` // NewAutoPwd is a new password that the Automation uses when connecting to an instance.
UsersDeleted []*MongoDBUser `json:"usersDeleted"` // UsersDeleted are objects that define the authenticated users to be deleted from specified databases or from all databases
UsersWanted []*MongoDBUser `json:"usersWanted"` // UsersWanted is a list which contains the desired users at the project level.
AuthoritativeSet bool `json:"authoritativeSet"` // AuthoritativeSet indicates if the MongoDBUsers should be synced with the current list of UsersWanted
AutoAuthMechanism string `json:"autoAuthMechanism"` // AutoAuthMechanism is the currently active agent authentication mechanism. This is a read only field
AutoAuthMechanisms []string `json:"autoAuthMechanisms,omitempty"` // AutoAuthMechanisms is a list of auth mechanisms the Automation Agent is able to use
AutoAuthRestrictions []interface{} `json:"autoAuthRestrictions"`
AutoKerberosKeytabPath string `json:"autoKerberosKeytabPath,omitempty"`
AutoLdapGroupDN string `json:"autoLdapGroupDN,omitempty"` //nolint:tagliatelle // AutoLdapGroupDN follows go convention while tag is correct from API
AutoPwd string `json:"autoPwd,omitempty"` // AutoPwd is a required field when going from `Disabled=false` to `Disabled=true`
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
DeploymentAuthMechanisms []string `json:"deploymentAuthMechanisms,omitempty"` // DeploymentAuthMechanisms is a list of possible auth mechanisms that can be used within deployments
Disabled bool `json:"disabled"` // Disabled indicates if auth is disabled
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
Keyfile string `json:"keyfile,omitempty"` // Keyfile is the path to a keyfile with read & write permissions. It is a required field if `Disabled=false`
KeyfileWindows string `json:"keyfileWindows,omitempty"` // KeyfileWindows is required if `Disabled=false` even if the value is not used.
NewAutoPwd string `json:"newAutoPwd,omitempty"` // NewAutoPwd is a new password that the Automation uses when connecting to an instance.
UsersDeleted []*MongoDBDeletedUser `json:"usersDeleted"` // UsersDeleted are objects that define the authenticated users to be deleted from specified databases or from all databases
UsersWanted []*MongoDBUser `json:"usersWanted"` // UsersWanted is a list which contains the desired users at the project level.
}

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

// MongoDBDeletedUser user to delete from DBs list.
type MongoDBDeletedUser struct {
User string `json:"user"`
DBs []string `json:"dbs"` //nolint:tagliatelle // use dbs as in the API
}

// AuthenticationRestriction of a database user.
type AuthenticationRestriction struct {
ClientSource []string `json:"clientSource"`
Expand Down
4 changes: 2 additions & 2 deletions opsmngr/checkpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/go-test/deep"
)

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

func TestCheckpoints_List(t *testing.T) {
client, mux, teardown := setup()
Expand Down Expand Up @@ -263,7 +263,7 @@ func TestCheckpoints_Get(t *testing.T) {
client, mux, teardown := setup()
defer teardown()

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

mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/continuous_snapshots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

const (
clusterName = "Cluster0"
snapshotID = "6b5380e6jvn128560506942b" //nolint:gosec // not a credential
snapshotID = "6b5380e6jvn128560506942b" // #nosec G101 // not a credential
)

func TestContinuousSnapshots_List(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/go-test/deep"
)

const eventID = "b3ad04e680eef540be141abe" //nolint:gosec // not a credential
const eventID = "b3ad04e680eef540be141abe" // #nosec G101 // not a credential

func TestEvents_ListOrganizationEvents(t *testing.T) {
client, mux, teardown := setup()
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/global_api_key_whitelists.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net/http"
)

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

// GlobalAPIKeyWhitelistsService provides access to the global alerts related functions in the Ops Manager API.
//
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/global_api_key_whitelists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/go-test/deep"
)

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

func TestWhitelistAPIKeys_List(t *testing.T) {
client, mux, teardown := setup()
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/global_api_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"net/url"
)

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

// GlobalAPIKeysService provides access to the global alerts related functions in the Ops Manager API.
//
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/global_api_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
apiDesc = "test-apikeye"
ewmaqvdo = "ewmaqvdo"
testAPIKey = "test-apikey"
globalAPIKeyID = "5c47503320eef5699e1cce8d" //nolint:gosec // ID and not an actual key
globalAPIKeyID = "5c47503320eef5699e1cce8d" // #nosec G101 // ID and not an actual key
)

func TestAPIKeys_ListAPIKeys(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/maintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/go-test/deep"
)

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

func TestMaintenanceWindows_List(t *testing.T) {
client, mux, teardown := setup()
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/organization_api_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"net/url"
)

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

// APIKeysService is an interface for interfacing with the APIKeys.
type APIKeysService interface {
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/organizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/go-test/deep"
)

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

func TestOrganizations_GetAllOrganizations(t *testing.T) {
client, mux, teardown := setup()
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/project_api_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net/http"
)

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

// ProjectAPIKeysService is an interface for interfacing with the APIKeys.
type ProjectAPIKeysService interface {
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/teams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/go-test/deep"
)

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

func TestTeams_List(t *testing.T) {
client, mux, teardown := setup()
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type User struct {
Links []*Link `json:"links,omitempty"`
MobileNumber string `json:"mobileNumber,omitempty"`
Password string `json:"password,omitempty"`
TeamIds []string `json:"teamIds,omitempty"`
TeamIds []string `json:"teamIds,omitempty"` //nolint:all // used as in the API
Roles []*UserRole `json:"roles,omitempty"`
Username string `json:"username"`
Country string `json:"country,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion opsmngr/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/go-test/deep"
)

const userID = "56a10a80e4b0fd3b9a9bb0c2" //nolint:gosec // not a credential
const userID = "56a10a80e4b0fd3b9a9bb0c2" // #nosec G101 // not a credential
const userName = "[email protected]"

func TestUsers_Get(t *testing.T) {
Expand Down