-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add oci_certificates_certificate_bundle and oci_certificates_certific…
…ate_authority_bundle data sources
- Loading branch information
Showing
68 changed files
with
3,801 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. | ||
// Licensed under the Mozilla Public License v2.0 | ||
|
||
package client | ||
|
||
import ( | ||
oci_certificates "github.com/oracle/oci-go-sdk/v65/certificates" | ||
oci_common "github.com/oracle/oci-go-sdk/v65/common" | ||
) | ||
|
||
func init() { | ||
RegisterOracleClient("oci_certificates.CertificatesClient", &OracleClient{InitClientFn: initCertificatesCertificatesClient}) | ||
} | ||
|
||
func initCertificatesCertificatesClient(configProvider oci_common.ConfigurationProvider, configureClient ConfigureClient, serviceClientOverrides ServiceClientOverrides) (interface{}, error) { | ||
client, err := oci_certificates.NewCertificatesClientWithConfigurationProvider(configProvider) | ||
if err != nil { | ||
return nil, err | ||
} | ||
err = configureClient(&client.BaseClient) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if serviceClientOverrides.HostUrlOverride != "" { | ||
client.Host = serviceClientOverrides.HostUrlOverride | ||
} | ||
return &client, nil | ||
} | ||
|
||
func (m *OracleClients) CertificatesClient() *oci_certificates.CertificatesClient { | ||
return m.GetClient("oci_certificates.CertificatesClient").(*oci_certificates.CertificatesClient) | ||
} |
61 changes: 61 additions & 0 deletions
61
internal/integrationtest/certificates_certificate_authority_bundle_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. | ||
// Licensed under the Mozilla Public License v2.0 | ||
|
||
package integrationtest | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/oracle/terraform-provider-oci/httpreplay" | ||
"github.com/oracle/terraform-provider-oci/internal/acctest" | ||
|
||
"github.com/oracle/terraform-provider-oci/internal/utils" | ||
) | ||
|
||
var ( | ||
CertificatesCertificateAuthorityBundleSingularDataSourceRepresentation = map[string]interface{}{ | ||
"certificate_authority_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_certificates_management_certificate_authority.test_certificate_authority.id}`}, | ||
"stage": acctest.Representation{RepType: acctest.Optional, Create: `CURRENT`}, | ||
} | ||
|
||
CertificatesCertificateAuthorityBundleResourceConfig = acctest.GenerateResourceFromRepresentationMap("oci_certificates_management_certificate_authority", "test_certificate_authority", acctest.Required, acctest.Create, certificateAuthorityRepresentation) | ||
) | ||
|
||
// issue-routing-tag: certificates/default | ||
func TestCertificatesCertificateAuthorityBundleResource_basic(t *testing.T) { | ||
httpreplay.SetScenario("TestCertificatesCertificateAuthorityBundleResource_basic") | ||
defer httpreplay.SaveScenario() | ||
|
||
config := acctest.ProviderTestConfig() | ||
|
||
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid") | ||
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId) | ||
|
||
singularDatasourceName := "data.oci_certificates_certificate_authority_bundle.test_certificate_authority_bundle" | ||
|
||
acctest.SaveConfigContent("", "", "", t) | ||
acctest.ResourceTest(t, nil, []resource.TestStep{ | ||
// verify singular datasource | ||
{ | ||
Config: config + | ||
acctest.GenerateDataSourceFromRepresentationMap("oci_certificates_certificate_authority_bundle", "test_certificate_authority_bundle", acctest.Optional, acctest.Create, CertificatesCertificateAuthorityBundleSingularDataSourceRepresentation) + | ||
compartmentIdVariableStr + CertificatesCertificateAuthorityBundleResourceConfig, | ||
Check: acctest.ComposeAggregateTestCheckFuncWrapper( | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "cert_chain_pem"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_authority_id"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_authority_name"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_pem"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "serial_number"), | ||
resource.TestCheckResourceAttr(singularDatasourceName, "stages.#", "2"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"), | ||
resource.TestCheckResourceAttr(singularDatasourceName, "validity.#", "1"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "validity.0.time_of_validity_not_before"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "validity.0.time_of_validity_not_after"), | ||
resource.TestCheckResourceAttr(singularDatasourceName, "version_number", "1"), | ||
), | ||
}, | ||
}) | ||
} |
64 changes: 64 additions & 0 deletions
64
internal/integrationtest/certificates_certificate_bundle_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. | ||
// Licensed under the Mozilla Public License v2.0 | ||
|
||
package integrationtest | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/oracle/terraform-provider-oci/httpreplay" | ||
"github.com/oracle/terraform-provider-oci/internal/acctest" | ||
|
||
"github.com/oracle/terraform-provider-oci/internal/utils" | ||
) | ||
|
||
var ( | ||
CertificatesCertificateBundleSingularDataSourceRepresentation = map[string]interface{}{ | ||
"certificate_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_certificates_management_certificate.test_certificate.id}`}, | ||
"certificate_bundle_type": acctest.Representation{RepType: acctest.Optional, Create: `CERTIFICATE_CONTENT_WITH_PRIVATE_KEY`}, | ||
"stage": acctest.Representation{RepType: acctest.Optional, Create: `CURRENT`}, | ||
} | ||
|
||
CertificatesCertificateBundleResourceConfig = acctest.GenerateResourceFromRepresentationMap("oci_certificates_management_certificate", "test_certificate", acctest.Required, acctest.Create, certificatesManagementCertificateRepresentation) | ||
) | ||
|
||
// issue-routing-tag: certificates/default | ||
func TestCertificatesCertificateBundleResource_basic(t *testing.T) { | ||
httpreplay.SetScenario("TestCertificatesCertificateBundleResource_basic") | ||
defer httpreplay.SaveScenario() | ||
|
||
config := acctest.ProviderTestConfig() | ||
|
||
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid") | ||
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId) | ||
|
||
singularDatasourceName := "data.oci_certificates_certificate_bundle.test_certificate_bundle" | ||
|
||
acctest.SaveConfigContent("", "", "", t) | ||
acctest.ResourceTest(t, nil, []resource.TestStep{ | ||
// verify singular datasource | ||
{ | ||
Config: config + | ||
acctest.GenerateDataSourceFromRepresentationMap("oci_certificates_certificate_bundle", "test_certificate_bundle", acctest.Optional, acctest.Create, CertificatesCertificateBundleSingularDataSourceRepresentation) + | ||
compartmentIdVariableStr + CertificatesCertificateBundleResourceConfig, | ||
Check: acctest.ComposeAggregateTestCheckFuncWrapper( | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "cert_chain_pem"), | ||
resource.TestCheckResourceAttr(singularDatasourceName, "certificate_bundle_type", "CERTIFICATE_CONTENT_WITH_PRIVATE_KEY"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_id"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_name"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "certificate_pem"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "private_key_pem"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "serial_number"), | ||
resource.TestCheckResourceAttr(singularDatasourceName, "stages.#", "2"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "time_created"), | ||
resource.TestCheckResourceAttr(singularDatasourceName, "validity.#", "1"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "validity.0.time_of_validity_not_before"), | ||
resource.TestCheckResourceAttrSet(singularDatasourceName, "validity.0.time_of_validity_not_after"), | ||
resource.TestCheckResourceAttr(singularDatasourceName, "version_number", "1"), | ||
), | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.