diff --git a/internal/btpcli/facade_accounts_resource_provider.go b/internal/btpcli/facade_accounts_resource_provider.go index fe0b5127..5ea97a06 100644 --- a/internal/btpcli/facade_accounts_resource_provider.go +++ b/internal/btpcli/facade_accounts_resource_provider.go @@ -33,7 +33,7 @@ func (f *accountsResourceProviderFacade) Get(ctx context.Context, provider strin })) } -type GlobalaccountResourceProviderCreateInput struct { +type GlobalaccountResourceProviderCreateUpdateInput struct { Provider string `btpcli:"provider"` TechnicalName string `btpcli:"technicalName"` DisplayName string `btpcli:"displayName"` @@ -42,7 +42,7 @@ type GlobalaccountResourceProviderCreateInput struct { Globalaccount string `btpcli:"globalAccount"` } -func (f *accountsResourceProviderFacade) Create(ctx context.Context, args GlobalaccountResourceProviderCreateInput) (provisioning.ResourceProviderResponseObject, CommandResponse, error) { +func (f *accountsResourceProviderFacade) Create(ctx context.Context, args GlobalaccountResourceProviderCreateUpdateInput) (provisioning.ResourceProviderResponseObject, CommandResponse, error) { args.Globalaccount = f.cliClient.GetGlobalAccountSubdomain() params, err := tfutils.ToBTPCLIParamsMap(args) @@ -53,6 +53,17 @@ func (f *accountsResourceProviderFacade) Create(ctx context.Context, args Global return doExecute[provisioning.ResourceProviderResponseObject](f.cliClient, ctx, NewCreateRequest(f.getCommand(), params)) } +func (f *accountsResourceProviderFacade) Update(ctx context.Context, args GlobalaccountResourceProviderCreateUpdateInput) (provisioning.ResourceProviderResponseObject, CommandResponse, error) { + args.Globalaccount = f.cliClient.GetGlobalAccountSubdomain() + params, err := tfutils.ToBTPCLIParamsMap(args) + + if err != nil { + return provisioning.ResourceProviderResponseObject{}, CommandResponse{}, err + } + + return doExecute[provisioning.ResourceProviderResponseObject](f.cliClient, ctx, NewUpdateRequest(f.getCommand(), params)) +} + func (f *accountsResourceProviderFacade) Delete(ctx context.Context, provider string, technicalName string) (provisioning.ResourceProviderResponseObject, CommandResponse, error) { return doExecute[provisioning.ResourceProviderResponseObject](f.cliClient, ctx, NewDeleteRequest(f.getCommand(), map[string]string{ "globalAccount": f.cliClient.GetGlobalAccountSubdomain(), diff --git a/internal/btpcli/facade_accounts_resource_provider_test.go b/internal/btpcli/facade_accounts_resource_provider_test.go index 458db7a9..d5c7f645 100644 --- a/internal/btpcli/facade_accounts_resource_provider_test.go +++ b/internal/btpcli/facade_accounts_resource_provider_test.go @@ -65,8 +65,8 @@ func TestAccountsResourceProviderFacade_Create(t *testing.T) { provider := "AWS" technicalName := "my_id" - description := "my-description" displayName := "My display name" + description := "my-description" configuration := "{}" t.Run("constructs the CLI params correctly", func(t *testing.T) { @@ -79,14 +79,54 @@ func TestAccountsResourceProviderFacade_Create(t *testing.T) { "globalAccount": "795b53bb-a3f0-4769-adf0-26173282a975", "provider": provider, "technicalName": technicalName, + "displayName": displayName, "description": description, + "configurationInfo": configuration, + }) + })) + defer srv.Close() + + _, res, err := uut.Accounts.ResourceProvider.Create(context.TODO(), GlobalaccountResourceProviderCreateUpdateInput{ + Provider: provider, + TechnicalName: technicalName, + Description: description, + DisplayName: displayName, + Configuration: configuration, + }) + + if assert.True(t, srvCalled) && assert.NoError(t, err) { + assert.Equal(t, 200, res.StatusCode) + } + }) +} + +func TestAccountsResourceProviderFacade_Update(t *testing.T) { + command := "accounts/resource-provider" + + provider := "AWS" + technicalName := "my_id" + displayName := "My display name" + description := "my-description" + configuration := "{}" + + t.Run("constructs the CLI params correctly", func(t *testing.T) { + var srvCalled bool + + uut, srv := prepareClientFacadeForTest(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + srvCalled = true + + assertCall(t, r, command, ActionUpdate, map[string]string{ + "globalAccount": "795b53bb-a3f0-4769-adf0-26173282a975", + "provider": provider, + "technicalName": technicalName, "displayName": displayName, + "description": description, "configurationInfo": configuration, }) })) defer srv.Close() - _, res, err := uut.Accounts.ResourceProvider.Create(context.TODO(), GlobalaccountResourceProviderCreateInput{ + _, res, err := uut.Accounts.ResourceProvider.Update(context.TODO(), GlobalaccountResourceProviderCreateUpdateInput{ Provider: provider, TechnicalName: technicalName, Description: description, diff --git a/internal/provider/fixtures/resource_globalaccount_resource_provider.update.yaml b/internal/provider/fixtures/resource_globalaccount_resource_provider.update.yaml new file mode 100644 index 00000000..2cc0ddef --- /dev/null +++ b/internal/provider/fixtures/resource_globalaccount_resource_provider.update.yaml @@ -0,0 +1,1315 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 3a463aed-5c31-8fe2-8ae5-2b266a270027 + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:17 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 98c4e649-9735-47de-4638-2561bd5ed1a0 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 560.734767ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 2cc4cc24-91d4-1eb6-04d5-aa84cfaf914e + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:17 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 5da9cf6e-412f-48f2-41d1-3c9b0538058b + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 358.177317ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 81015e41-66af-2d73-eda0-c9413eb1256c + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:18 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 32e5a05b-4954-4515-5a68-bd702bbdbfd0 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 241.23142ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 337 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"paramValues":{"configurationInfo":"{\"access_key_id\":\"AWSACCESSKEY\",\"secret_access_key\":\"AWSSECRETKEY\",\"vpc_id\":\"vpc-test\",\"region\":\"eu-central-1\"}","description":"My description","displayName":"My AWS Resource Provider","globalAccount":"terraformintcanary","provider":"AWS","technicalName":"my_aws_resource_provider"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 2feef465-2bdb-d59a-dccc-fb154c4ddfd6 + X-Cpcli-Customidp: + - "" + X-Cpcli-Format: + - json + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Subdomain: + - terraformintcanary + url: https://cpcli.cf.sap.hana.ondemand.com/command/v2.38.0/accounts/resource-provider?create + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"technicalName":"my_aws_resource_provider","displayName":"My AWS Resource Provider","description":"My description","resourceType":"IAAS_ACCOUNT","resourceProvider":"AWS","additionalInfo":{"access_key_id":"AWSACCESSKEY","secret_access_key":"AWSSECRETKEY","vpc_id":"vpc-test","region":"eu-central-1"}}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:18 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Cpcli-Backend-Mediatype: + - application/json;charset=UTF-8 + X-Cpcli-Backend-Status: + - "200" + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Replacementrefreshtoken: + - redacted + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - c64317fd-48b4-4503-44d4-a0fdddf18218 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 388.469275ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - c609e21b-5cdd-e0f4-8fc6-8389041e23df + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:19 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 4de8bfb3-0180-478a-5ddf-3685650b39ff + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 383.013017ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - d2b94391-9728-a1c7-fd12-4e0ea86a8138 + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:19 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - a3b898f1-4170-43de-581d-bb9e8c5dffc2 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 376.794299ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 115 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"paramValues":{"globalAccount":"terraformintcanary","provider":"AWS","technicalName":"my_aws_resource_provider"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 56492001-5b6f-fc76-b6d2-bc78aacd68ca + X-Cpcli-Customidp: + - "" + X-Cpcli-Format: + - json + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Subdomain: + - terraformintcanary + url: https://cpcli.cf.sap.hana.ondemand.com/command/v2.38.0/accounts/resource-provider?get + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"technicalName":"my_aws_resource_provider","displayName":"My AWS Resource Provider","description":"My description","resourceType":"IAAS_ACCOUNT","resourceProvider":"AWS","additionalInfo":{"access_key_id":"AWSACCESSKEY","secret_access_key":"AWSSECRETKEY","vpc_id":"vpc-test","region":"eu-central-1"}}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:19 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Cpcli-Backend-Mediatype: + - application/json;charset=UTF-8 + X-Cpcli-Backend-Status: + - "200" + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Replacementrefreshtoken: + - redacted + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - d9cc5c14-158e-483c-5d15-600a33f289f4 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 407.876271ms + - id: 7 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 8ec1ab07-51d7-1c0e-5843-e26572775f84 + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:20 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 57d128f5-2374-436c-536d-20e90a982164 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 329.823099ms + - id: 8 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 2aa9fd07-6aac-dce8-cfae-b870649fb255 + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:20 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 1b8473a8-03de-44c3-4f8d-016689dd7bd8 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 260.34002ms + - id: 9 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 115 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"paramValues":{"globalAccount":"terraformintcanary","provider":"AWS","technicalName":"my_aws_resource_provider"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 47bc719b-9b14-2669-dbbb-38c593441b47 + X-Cpcli-Customidp: + - "" + X-Cpcli-Format: + - json + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Subdomain: + - terraformintcanary + url: https://cpcli.cf.sap.hana.ondemand.com/command/v2.38.0/accounts/resource-provider?get + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"technicalName":"my_aws_resource_provider","displayName":"My AWS Resource Provider","description":"My description","resourceType":"IAAS_ACCOUNT","resourceProvider":"AWS","additionalInfo":{"access_key_id":"AWSACCESSKEY","secret_access_key":"AWSSECRETKEY","vpc_id":"vpc-test","region":"eu-central-1"}}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:21 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Cpcli-Backend-Mediatype: + - application/json;charset=UTF-8 + X-Cpcli-Backend-Status: + - "200" + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Replacementrefreshtoken: + - redacted + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 7b9b5c08-46ff-4203-7b9e-984c7172a9c5 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 399.614939ms + - id: 10 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 04978bc0-5e21-3375-2f35-cccabce5d073 + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:21 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 43e5fe21-9c71-498a-7c44-a138745b8b20 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 241.765182ms + - id: 11 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 039e77f2-819c-c013-45fd-4d8b414c1f87 + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:22 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 899024fa-643b-4bbc-7f47-3654905f5f8a + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 236.517724ms + - id: 12 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 298 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"paramValues":{"configurationInfo":"{\"access_key_id\":\"AWSACCESSKEY\",\"secret_access_key\":\"AWSSECRETKEY\",\"vpc_id\":\"vpc-test\",\"region\":\"us-east-1\"}","displayName":"My New Display Name","globalAccount":"terraformintcanary","provider":"AWS","technicalName":"my_aws_resource_provider"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 4aed9a85-f513-77ef-102e-dea471b8ccd0 + X-Cpcli-Customidp: + - "" + X-Cpcli-Format: + - json + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Subdomain: + - terraformintcanary + url: https://cpcli.cf.sap.hana.ondemand.com/command/v2.38.0/accounts/resource-provider?update + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"technicalName":"my_aws_resource_provider","displayName":"My New Display Name","resourceType":"IAAS_ACCOUNT","resourceProvider":"AWS","additionalInfo":{"access_key_id":"AWSACCESSKEY","secret_access_key":"AWSSECRETKEY","vpc_id":"vpc-test","region":"us-east-1"}}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:22 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Cpcli-Backend-Mediatype: + - application/json;charset=UTF-8 + X-Cpcli-Backend-Status: + - "200" + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Replacementrefreshtoken: + - redacted + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 593a3cb9-ec4d-4d6e-421a-90ceb8b6af57 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 267.256746ms + - id: 13 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - a51f7944-50b9-7063-7658-dad9ca813453 + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:22 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - ff167ee0-b8cc-417e-6f29-b6c30c9bfcc6 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 312.565292ms + - id: 14 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 19c1a49d-3de6-334f-d087-8243379ce284 + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:23 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 3f15b42a-10ef-47d7-5e67-5ea62b04c688 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 239.472421ms + - id: 15 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 115 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"paramValues":{"globalAccount":"terraformintcanary","provider":"AWS","technicalName":"my_aws_resource_provider"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - c9d34151-1f04-4f20-f936-d6dee313bfa2 + X-Cpcli-Customidp: + - "" + X-Cpcli-Format: + - json + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Subdomain: + - terraformintcanary + url: https://cpcli.cf.sap.hana.ondemand.com/command/v2.38.0/accounts/resource-provider?get + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"technicalName":"my_aws_resource_provider","displayName":"My New Display Name","resourceType":"IAAS_ACCOUNT","resourceProvider":"AWS","additionalInfo":{"access_key_id":"AWSACCESSKEY","secret_access_key":"AWSSECRETKEY","vpc_id":"vpc-test","region":"us-east-1"}}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:23 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Cpcli-Backend-Mediatype: + - application/json;charset=UTF-8 + X-Cpcli-Backend-Status: + - "200" + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Replacementrefreshtoken: + - redacted + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 6aa12733-8f50-4b25-4d06-8a7d34e3fe5b + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 216.525305ms + - id: 16 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 7ee1b220-6272-6dba-5a29-0987af53c717 + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:23 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 7fe14f6c-2703-46d0-7d42-8c4645bc0ee5 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 235.586016ms + - id: 17 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 76e85db3-0748-d1df-704e-eb98d353f127 + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:24 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - f36f5d0e-f259-410b-6f01-25780c6daa75 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 305.339637ms + - id: 18 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 127 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"customIdp":"","subdomain":"terraformintcanary","userName":"john.doe@int.test","password":"redacted"} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 387e0cbc-619e-9b04-4043-19321cb950f2 + X-Cpcli-Format: + - json + url: https://cpcli.cf.sap.hana.ondemand.com/login/v2.38.0 + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 162 + uncompressed: false + body: '{"issuer":"accounts.sap.com","refreshToken":"redacted","user":"john.doe@int.test","mail":"john.doe@int.test"}' + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Length: + - "162" + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:24 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - b6eb2533-f9c8-49e0-76e3-bb9a5397ee0f + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 383.141346ms + - id: 19 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 132 + transfer_encoding: [] + trailer: {} + host: cpcli.cf.sap.hana.ondemand.com + remote_addr: "" + request_uri: "" + body: | + {"paramValues":{"confirm":"true","globalAccount":"terraformintcanary","provider":"AWS","technicalName":"my_aws_resource_provider"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Terraform/1.5.0 terraform-provider-btp/dev + X-Correlationid: + - 6a0e5d4b-7cbe-1c59-5086-aa32f8f66159 + X-Cpcli-Customidp: + - "" + X-Cpcli-Format: + - json + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Subdomain: + - terraformintcanary + url: https://cpcli.cf.sap.hana.ondemand.com/command/v2.38.0/accounts/resource-provider?delete + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: "null" + headers: + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Content-Type: + - application/json + Date: + - Thu, 27 Jul 2023 12:45:25 GMT + Expires: + - "0" + Pragma: + - no-cache + Referrer-Policy: + - no-referrer + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Cpcli-Backend-Mediatype: + - application/json;charset=UTF-8 + X-Cpcli-Backend-Status: + - "200" + X-Cpcli-Refreshtoken: + - redacted + X-Cpcli-Replacementrefreshtoken: + - redacted + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 13efbd46-c096-499b-7481-a2fc29565477 + X-Xss-Protection: + - "0" + status: 200 OK + code: 200 + duration: 406.938668ms diff --git a/internal/provider/resource_globalaccount_resource_provider.go b/internal/provider/resource_globalaccount_resource_provider.go index f40258c5..f58d2f2d 100644 --- a/internal/provider/resource_globalaccount_resource_provider.go +++ b/internal/provider/resource_globalaccount_resource_provider.go @@ -129,7 +129,7 @@ func (rs *resourceGlobalaccountProviderResource) Create(ctx context.Context, req return } - cliRes, _, err := rs.cli.Accounts.ResourceProvider.Create(ctx, btpcli.GlobalaccountResourceProviderCreateInput{ + cliRes, _, err := rs.cli.Accounts.ResourceProvider.Create(ctx, btpcli.GlobalaccountResourceProviderCreateUpdateInput{ Provider: plan.Provider.ValueString(), TechnicalName: plan.TechnicalName.ValueString(), DisplayName: plan.DisplayName.ValueString(), @@ -156,20 +156,23 @@ func (rs *resourceGlobalaccountProviderResource) Update(ctx context.Context, req return } - resp.Diagnostics.AddError("API Error Updating Resource Resource Provider (Global Account)", "Update is not yet implemented.") - - /* TODO: implementation of UPDATE operation - cliRes, err := gen.client.Execute(ctx, btpcli.Update, gen.command, plan) + cliRes, _, err := rs.cli.Accounts.ResourceProvider.Update(ctx, btpcli.GlobalaccountResourceProviderCreateUpdateInput{ + Provider: plan.Provider.ValueString(), + TechnicalName: plan.TechnicalName.ValueString(), + DisplayName: plan.DisplayName.ValueString(), + Description: plan.Description.ValueString(), + Configuration: plan.Configuration.ValueString(), + }) if err != nil { resp.Diagnostics.AddError("API Error Updating Resource Resource Provider (Global Account)", fmt.Sprintf("%s", err)) return - }*/ + } - diags = resp.State.Set(ctx, plan) + state, diags := globalaccountResourceProviderValueFrom(ctx, cliRes) + resp.Diagnostics.Append(diags...) + + diags = resp.State.Set(ctx, &state) resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } } func (rs *resourceGlobalaccountProviderResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { diff --git a/internal/provider/resource_globalaccount_resource_provider_test.go b/internal/provider/resource_globalaccount_resource_provider_test.go index f66043b3..ed5f73fa 100644 --- a/internal/provider/resource_globalaccount_resource_provider_test.go +++ b/internal/provider/resource_globalaccount_resource_provider_test.go @@ -2,6 +2,7 @@ package provider import ( "fmt" + "regexp" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -52,6 +53,122 @@ func TestResourceGlobalaccountResourceProvider(t *testing.T) { }) }) + t.Run("happy path - update", func(t *testing.T) { + rec := setupVCR(t, "fixtures/resource_globalaccount_resource_provider.update") + defer stopQuietly(rec) + + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: getProviders(rec.GetDefaultClient()), + Steps: []resource.TestStep{ + { + Config: hclProvider() + hclResourceGlobalaccountResourceProvider("uut", + "AWS", + "my_aws_resource_provider", + "My AWS Resource Provider", + "My description", + "{\"access_key_id\":\"AWSACCESSKEY\",\"secret_access_key\":\"AWSSECRETKEY\",\"vpc_id\":\"vpc-test\",\"region\":\"eu-central-1\"}", + ), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("btp_globalaccount_resource_provider.uut", "provider_type", "AWS"), + resource.TestCheckResourceAttr("btp_globalaccount_resource_provider.uut", "technical_name", "my_aws_resource_provider"), + resource.TestCheckResourceAttr("btp_globalaccount_resource_provider.uut", "id", "my_aws_resource_provider"), + resource.TestCheckResourceAttr("btp_globalaccount_resource_provider.uut", "display_name", "My AWS Resource Provider"), + resource.TestCheckResourceAttr("btp_globalaccount_resource_provider.uut", "description", "My description"), + resource.TestCheckResourceAttr("btp_globalaccount_resource_provider.uut", "configuration", "{\"access_key_id\":\"AWSACCESSKEY\",\"secret_access_key\":\"AWSSECRETKEY\",\"vpc_id\":\"vpc-test\",\"region\":\"eu-central-1\"}"), + ), + }, + { + Config: hclProvider() + hclResourceGlobalaccountResourceProviderNoDesc("uut", + "AWS", + "my_aws_resource_provider", + "My New Display Name", + "{\"access_key_id\":\"AWSACCESSKEY\",\"secret_access_key\":\"AWSSECRETKEY\",\"vpc_id\":\"vpc-test\",\"region\":\"us-east-1\"}", + ), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("btp_globalaccount_resource_provider.uut", "provider_type", "AWS"), + resource.TestCheckResourceAttr("btp_globalaccount_resource_provider.uut", "technical_name", "my_aws_resource_provider"), + resource.TestCheckResourceAttr("btp_globalaccount_resource_provider.uut", "display_name", "My New Display Name"), + resource.TestCheckResourceAttr("btp_globalaccount_resource_provider.uut", "description", ""), + resource.TestCheckResourceAttr("btp_globalaccount_resource_provider.uut", "configuration", "{\"access_key_id\":\"AWSACCESSKEY\",\"secret_access_key\":\"AWSSECRETKEY\",\"vpc_id\":\"vpc-test\",\"region\":\"us-east-1\"}"), + ), + }, + }, + }) + }) + + t.Run("error path - provider_type is mandatory", func(t *testing.T) { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: getProviders(nil), + Steps: []resource.TestStep{ + { + Config: hclProvider() + ` +resource "btp_globalaccount_resource_provider" "uut" { + technical_name = "technical_name" + display_name = "display_name" + configuration = "configuration" +}`, + ExpectError: regexp.MustCompile(`The argument "provider_type" is required, but no definition was found.`), + }, + }, + }) + }) + + t.Run("error path - technical_name is mandatory", func(t *testing.T) { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: getProviders(nil), + Steps: []resource.TestStep{ + { + Config: hclProvider() + ` +resource "btp_globalaccount_resource_provider" "uut" { + provider_type = "provider_type" + display_name = "display_name" + configuration = "configuration" +}`, + ExpectError: regexp.MustCompile(`The argument "technical_name" is required, but no definition was found.`), + }, + }, + }) + }) + + t.Run("error path - display_name is mandatory", func(t *testing.T) { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: getProviders(nil), + Steps: []resource.TestStep{ + { + Config: hclProvider() + ` +resource "btp_globalaccount_resource_provider" "uut" { + provider_type = "provider_type" + technical_name = "technical_name" + configuration = "configuration" +}`, + ExpectError: regexp.MustCompile(`The argument "display_name" is required, but no definition was found.`), + }, + }, + }) + }) + + t.Run("error path - configuration is mandatory", func(t *testing.T) { + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: getProviders(nil), + Steps: []resource.TestStep{ + { + Config: hclProvider() + ` +resource "btp_globalaccount_resource_provider" "uut" { + provider_type = "provider_type" + technical_name = "technical_name" + display_name = "display_name" +}`, + ExpectError: regexp.MustCompile(`The argument "configuration" is required, but no definition was found.`), + }, + }, + }) + }) + } func hclResourceGlobalaccountResourceProvider(resourceName string, provider string, technicalName string, displayName string, description string, configuration string) string {