diff --git a/client/cost_credentials_project_assignment.go b/client/cost_credentials_project_assignment.go index f9f5d5b7..0779f007 100644 --- a/client/cost_credentials_project_assignment.go +++ b/client/cost_credentials_project_assignment.go @@ -9,7 +9,9 @@ type CostCredentialProjectAssignment struct { func (client *ApiClient) AssignCostCredentialsToProject(projectId string, credentialId string) (CostCredentialProjectAssignment, error) { var result CostCredentialProjectAssignment - err := client.http.Put("/costs/project/"+projectId+"/credentials", credentialId, &result) + err := client.http.Put("/costs/project/"+projectId+"/credentials", map[string]string{ + "credentialsId": credentialId, + }, &result) if err != nil { return result, err } @@ -22,7 +24,7 @@ func (client *ApiClient) RemoveCostCredentialsFromProject(projectId string, cred func (client *ApiClient) CostCredentialIdsInProject(projectId string) ([]CostCredentialProjectAssignment, error) { var result []CostCredentialProjectAssignment - err := client.http.Get("/costs/project/"+projectId, nil, &result) + err := client.http.Get("/costs/project/"+projectId+"/credentials", nil, &result) if err != nil { return nil, err diff --git a/client/cost_credentials_project_assignment_test.go b/client/cost_credentials_project_assignment_test.go index f6e6620c..86ea289f 100644 --- a/client/cost_credentials_project_assignment_test.go +++ b/client/cost_credentials_project_assignment_test.go @@ -24,7 +24,7 @@ var _ = Describe(" Cost Credentials Project Assignment", func() { BeforeEach(func() { httpCall = mockHttpClient.EXPECT(). - Put("/costs/project/"+projectId+"/credentials", credentialId, gomock.Any()). + Put("/costs/project/"+projectId+"/credentials", map[string]string{"credentialsId": credentialId}, gomock.Any()). Do(func(path string, request interface{}, response *CostCredentialProjectAssignment) { *response = expectedResponse }).Times(1) @@ -41,7 +41,7 @@ var _ = Describe(" Cost Credentials Project Assignment", func() { var actualError error BeforeEach(func() { httpCall = mockHttpClient.EXPECT(). - Put("/costs/project/"+projectId+"/credentials", credentialId, gomock.Any()). + Put("/costs/project/"+projectId+"/credentials", map[string]string{"credentialsId": credentialId}, gomock.Any()). Return(errors.New(errorInfo)). Times(1) _, actualError = apiClient.AssignCostCredentialsToProject(projectId, credentialId) @@ -93,7 +93,7 @@ var _ = Describe(" Cost Credentials Project Assignment", func() { expectedResponse := []CostCredentialProjectAssignment{firstResulteResponse, secondResulteResponse} BeforeEach(func() { httpCall = mockHttpClient.EXPECT(). - Get("/costs/project/"+projectId, nil, gomock.Any()). + Get("/costs/project/"+projectId+"/credentials", nil, gomock.Any()). Do(func(path string, request interface{}, response *[]CostCredentialProjectAssignment) { *response = expectedResponse }).Times(1) @@ -110,7 +110,7 @@ var _ = Describe(" Cost Credentials Project Assignment", func() { var actualError error BeforeEach(func() { httpCall = mockHttpClient.EXPECT(). - Get("/costs/project/"+projectId, nil, gomock.Any()). + Get("/costs/project/"+projectId+"/credentials", nil, gomock.Any()). Return(errors.New(errorInfo)). Times(1) _, actualError = apiClient.CostCredentialIdsInProject(projectId) diff --git a/tests/integration/023_cost_credentials_project_assignment/conf.tf b/tests/integration/023_cost_credentials_project_assignment/conf.tf new file mode 100644 index 00000000..8d6d2954 --- /dev/null +++ b/tests/integration/023_cost_credentials_project_assignment/conf.tf @@ -0,0 +1,15 @@ +terraform { + backend "local" { + } + required_providers { + env0 = { + source = "terraform-registry.env0.com/env0/env0" + } + } +} + +provider "env0" {} + +variable "second_run" { + default = false +} diff --git a/tests/integration/023_cost_credentials_project_assignment/expected_outputs.json b/tests/integration/023_cost_credentials_project_assignment/expected_outputs.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/tests/integration/023_cost_credentials_project_assignment/expected_outputs.json @@ -0,0 +1 @@ +{} diff --git a/tests/integration/023_cost_credentials_project_assignment/main.tf b/tests/integration/023_cost_credentials_project_assignment/main.tf new file mode 100644 index 00000000..55bcd63e --- /dev/null +++ b/tests/integration/023_cost_credentials_project_assignment/main.tf @@ -0,0 +1,23 @@ +provider "random" {} + +resource "random_string" "random" { + length = 8 + special = false + min_lower = 8 +} + +resource "env0_project" "project" { + name = "Test-Project-${random_string.random.result}" + description = "description" +} + +resource "env0_aws_cost_credentials" "cost" { + name = "cost-${random_string.random.result}" + arn = "arn" + external_id = "externalid" +} + +resource "env0_cost_credentials_project_assignment" "cost_project_assignment" { + credential_id = env0_aws_cost_credentials.cost.id + project_id = env0_project.project.id +}