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

INTMDB-287: Fixes the issues in project api keys #639

Merged
merged 9 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .github/workflows/automated-test-acceptances.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ jobs:
MONGODB_ATLAS_ENABLE_BETA: ${{ secrets.MONGODB_ATLAS_ENABLE_BETA }}
ACCTEST_TIMEOUT: ${{ secrets.ACCTEST_TIMEOUT }}
PAGER_DUTY_SERVICE_KEY: ${{ secrets.PAGER_DUTY_SERVICE_KEY }}
MONGODB_ATLAS_API_KEYS_IDS: ${{ secrets.MONGODB_ATLAS_API_KEYS_IDS }}
run: make testacc
2 changes: 1 addition & 1 deletion mongodbatlas/data_source_mongodbatlas_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func getProjectAPIKeys(ctx context.Context, conn *matlas.Client, orgID, projectI
for _, role := range key.Roles {
// ProjectAPIKeys.List returns all API keys of the Project, including the org and project roles
// For more details: https://docs.atlas.mongodb.com/reference/api/projectApiKeys/get-all-apiKeys-in-one-project/
if !strings.HasPrefix(role.RoleName, "ORG_") {
if !strings.HasPrefix(role.RoleName, "ORG_") && role.GroupID == projectID {
roles = append(roles, role.RoleName)
}
}
Expand Down
5 changes: 4 additions & 1 deletion mongodbatlas/data_source_mongodbatlas_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestAccDataSourceMongoDBAtlasProject_byID(t *testing.T) {
t.Skip("`MONGODB_ATLAS_TEAMS_IDS` must have 2 team ids for this acceptance testing")
}
if len(apiKeysIds) < 2 {
t.Fatal("`MONGODB_ATLAS_API_KEYS_IDS` must have 2 api key ids for this acceptance testing")
t.Skip("`MONGODB_ATLAS_API_KEYS_IDS` must have 2 api key ids for this acceptance testing")
}

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -67,6 +67,9 @@ func TestAccDataSourceMongoDBAtlasProject_byName(t *testing.T) {
if len(teamsIds) < 2 {
t.Skip("`MONGODB_ATLAS_TEAMS_IDS` must have 2 team ids for this acceptance testing")
}
if len(apiKeysIds) < 2 {
t.Skip("`MONGODB_ATLAS_API_KEYS_IDS` must have 2 api key ids for this acceptance testing")
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) },
Expand Down
6 changes: 6 additions & 0 deletions mongodbatlas/data_source_mongodbatlas_projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func TestAccDataSourceMongoDBAtlasProjects_basic(t *testing.T) {
if len(teamsIds) < 2 {
t.Skip("`MONGODB_ATLAS_TEAMS_IDS` must have 2 team ids for this acceptance testing")
}
if len(apiKeysIds) < 2 {
t.Skip("`MONGODB_ATLAS_API_KEYS_IDS` must have 2 api key ids for this acceptance testing")
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) },
Expand Down Expand Up @@ -65,6 +68,9 @@ func TestAccDataSourceMongoDBAtlasProjects_withPagination(t *testing.T) {
if len(teamsIds) < 2 {
t.Skip("`MONGODB_ATLAS_TEAMS_IDS` must have 2 team ids for this acceptance testing")
}
if len(apiKeysIds) < 2 {
t.Skip("`MONGODB_ATLAS_API_KEYS_IDS` must have 2 api key ids for this acceptance testing")
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) },
Expand Down
2 changes: 1 addition & 1 deletion mongodbatlas/resource_mongodbatlas_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestAccResourceMongoDBAtlasProject_basic(t *testing.T) {
t.Skip("`MONGODB_ATLAS_TEAMS_IDS` must have 3 team ids for this acceptance testing")
}
if len(apiKeysIds) < 2 {
t.Fatal("`MONGODB_ATLAS_API_KEYS_IDS` must have 2 api key ids for this acceptance testing")
t.Skip("`MONGODB_ATLAS_API_KEYS_IDS` must have 2 api key ids for this acceptance testing")
}

resource.ParallelTest(t, resource.TestCase{
Expand Down