Skip to content

Commit 10e91d7

Browse files
authored
test: Fix database-user sample request helpers (#1448)
1 parent 1ec1b7f commit 10e91d7

File tree

5 files changed

+44
-52
lines changed

5 files changed

+44
-52
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ After the above 2 steps are completed and we've agreed on a path forward:
1010
2. Create a branch with a name that briefly describes your submission
1111
3. Add comments around your new code that explain what's happening
1212
4. Commit and push your changes to your branch then submit a pull request against the current release branch, not master. The naming scheme of the branch is `release-staging-v#.#.#`. **Note**: There will only be one release branch at a time.
13-
5. A repo maintainer will review the your pull request, and may either request additional changes or merge the pull request.
13+
5. A repo maintainer will review your pull request, and may either request additional changes or merge the pull request.
1414

1515
## Requirements
1616

17-
- Resources configurations, specifcally `.rpdk-config` and `Makefile` build commands, are compatible with cloudformation-cli (`cfn`) versions 0.2.34 and above.
17+
- Resources configurations, specifically `.rpdk-config` and `Makefile` build commands, are compatible with cloudformation-cli (`cfn`) versions 0.2.34 and above.
1818

1919

2020
## Code and Test Best Practices
2121

22-
- Each resource is implemented in a seperate directory within `./cfn-resources`. Under each resource directory operations will be implemented in `./cmd/resource/resource.go`, having a separate file `./cmd/resource/mappings.go` for defining conversion logic with respective SDK and CFN models.
22+
- Each resource is implemented in a separate directory within `./cfn-resources`. Under each resource directory operations will be implemented in `./cmd/resource/resource.go`, having a separate file `./cmd/resource/mappings.go` for defining conversion logic with respective SDK and CFN models.
2323
- Associated unit testing files must be defined for conversion logic, and can also exist for other business logic such as handling state transitions. Unit tests are defined under `resource_test` package to minimize coupling.
2424
- [Testify Mock](https://pkg.go.dev/github.com/stretchr/testify/mock) and [Mockery](https://github.com/vektra/mockery) are used for test doubles in unit tests. Mocked interfaces are generated in folder `cfn-resources/testutil/mocksvc`.
2525
- We have a `/test/README.md` for every resource in `cfn-resources`. You will also find [TESTING.md](./TESTING.md) which provides testing practices common to all resources.

TESTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This file contains the steps to follow to test any changes to the CFN resources.
77
### Prerequisites
88
- Install [AtlasCLI](https://www.mongodb.com/docs/atlas/cli/stable/install-atlas-cli/) and [configure the default profile](https://www.mongodb.com/docs/atlas/cli/stable/connect-atlas-cli/#select-a-connection-method) on your machine as the scripts use Atlas CLI
99
- Ensure [AWS CLI](https://aws.amazon.com/cli/), [CFN CLI](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/what-is-cloudformation-cli.html), [SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) are installed and configured correctly for your AWS account
10-
- Configure an Atlas profile secret in AWS account with your API keys. Refer [README](../../../README.md) for more information on how to do this
10+
- Configure an Atlas profile secret in AWS account with your API keys. Refer to [README](README.md) for more information on how to do this
1111
- Have Docker running on your machine
1212
- Refer to the prerequisites for your resource in the `cfn-resources/[resource-folder]/test`
1313

cfn-resources/database-user/test/databaseuser.create-sample-cfn-request.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ projectId="${1}"
2020
username="${2}"
2121
password="${3}"
2222

23-
jq --arg ProjectId "$projectId" \
23+
jq --arg projectId "$projectId" \
2424
--arg username "$username" \
2525
--arg password "$password" \
26-
'.desiredResourceState.properties.Username?|=$username | .desiredResourceState.properties.Password?|=$password | .desiredResourceState.properties.ProjectId?|=$projectId' \
26+
'.desiredResourceState.Username?|=$username | .desiredResourceState.Password?|=$password | .desiredResourceState.ProjectId?|=$projectId' \
2727
"$(dirname "$0")/databaseuser.sample-cfn-request.json"
Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
{
2-
"desiredResourceState" : {
3-
"resourceType" : "MongoDB::Atlas::DatabaseUser",
4-
"properties" : {
5-
"Username" : "Name",
6-
"ProjectId" : "ProjectId",
7-
"Profile" :"",
8-
"DatabaseName": "$external",
9-
"AWSIAMType": "ROLE",
10-
"Roles": [
11-
{ "RoleName": "readWrite",
12-
"DatabaseName": "testdb"
13-
}
14-
],
15-
"Scopes": [
16-
{ "Type": "CLUSTER",
17-
"Name": "testdb"
18-
}
19-
]
20-
21-
22-
}
23-
},
24-
"providerLogGroupName" : "mongodb-atlas-databaseuser-logs",
25-
"previousResourceState": { }
2+
"desiredResourceState" : {
3+
"Username": "Name",
4+
"ProjectId": "ProjectId",
5+
"Profile":"",
6+
"DatabaseName": "$external",
7+
"AWSIAMType": "ROLE",
8+
"Roles": [
9+
{ "RoleName": "readWrite",
10+
"DatabaseName": "testdb"
11+
}
12+
],
13+
"Scopes": [
14+
{ "Type": "CLUSTER",
15+
"Name": "testdb"
16+
}
17+
]
18+
},
19+
"providerLogGroupName" : "mongodb-atlas-databaseuser-logs",
20+
"previousResourceState": { }
2621
}
Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
{
2-
"desiredResourceState" : {
3-
"resourceType" : "MongoDB::Atlas::DatabaseUser",
4-
"properties" : {
5-
"Username" : "Name",
6-
"Password" : "Name",
7-
"ProjectId" : "ProjectId",
8-
"Profile" : "",
9-
"DatabaseName": "admin",
10-
"Roles": [
11-
{ "RoleName": "readWrite",
12-
"DatabaseName": "testdb"
13-
}
14-
],
15-
"Scopes": [
16-
{ "Type": "CLUSTER",
17-
"Name": "testdb"
18-
}
19-
]
20-
}
21-
},
22-
"providerLogGroupName" : "mongodb-atlas-databaseuser-logs",
23-
"previousResourceState": { }
2+
"desiredResourceState" : {
3+
"Username": "Name",
4+
"Password": "Name",
5+
"ProjectId": "ProjectId",
6+
"Profile": "",
7+
"DatabaseName": "admin",
8+
"Roles": [
9+
{ "RoleName": "readWrite",
10+
"DatabaseName": "testdb"
11+
}
12+
],
13+
"Scopes": [
14+
{ "Type": "CLUSTER",
15+
"Name": "testdb"
16+
}
17+
]
18+
},
19+
"providerLogGroupName" : "mongodb-atlas-databaseuser-logs",
20+
"previousResourceState": { }
2421
}

0 commit comments

Comments
 (0)