Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions internal/connector/pingfederate/pingfederate_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ func (c *PingFederateConnector) Export(format, outputDir string, overwriteExport
resources.CertificatesRevocationOCSPCertificate(&c.clientInfo),
resources.CertificatesRevocationSettings(&c.clientInfo),
resources.ClusterSettings(&c.clientInfo),
resources.ConfigurationEncryptionKeysRotate(&c.clientInfo),
resources.DataStore(&c.clientInfo),
resources.DefaultURLs(&c.clientInfo),
resources.ExtendedProperties(&c.clientInfo),
resources.IdentityStoreProvisioner(&c.clientInfo),
resources.IDPAdapter(&c.clientInfo),
resources.IDPSPConnection(&c.clientInfo),
resources.IdpStsRequestParametersContract(&c.clientInfo),
resources.IncomingProxySettings(&c.clientInfo),
resources.KerberosRealm(&c.clientInfo),
resources.LocalIdentityProfile(&c.clientInfo),
Expand Down
15 changes: 15 additions & 0 deletions internal/connector/pingfederate/pingfederate_connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ func TestPingFederateTerraformPlan(t *testing.T) {
"Error: PingFederate API error",
},
},
{
name: "PingFederateConfigurationEncryptionKeysRotate",
resource: resources.ConfigurationEncryptionKeysRotate(PingFederateClientInfo),
ignoredErrors: nil,
},
{
name: "PingFederateDataStore",
resource: resources.DataStore(PingFederateClientInfo),
Expand All @@ -105,6 +110,11 @@ func TestPingFederateTerraformPlan(t *testing.T) {
resource: resources.ExtendedProperties(PingFederateClientInfo),
ignoredErrors: nil,
},
{
name: "PingFederateIdentityStoreProvisioner",
resource: resources.IdentityStoreProvisioner(PingFederateClientInfo),
ignoredErrors: nil,
},
{
name: "PingFederateIDPAdapter",
resource: resources.IDPAdapter(PingFederateClientInfo),
Expand All @@ -115,6 +125,11 @@ func TestPingFederateTerraformPlan(t *testing.T) {
resource: resources.IDPSPConnection(PingFederateClientInfo),
ignoredErrors: nil,
},
{
name: "PingFederateIdpStsRequestParametersContract",
resource: resources.IdpStsRequestParametersContract(PingFederateClientInfo),
ignoredErrors: nil,
},
{
name: "PingFederateIncomingProxySettings",
resource: resources.IncomingProxySettings(PingFederateClientInfo),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (r *PingFederateAuthenticationApiApplicationResource) ExportAll() (*[]conne

for appId, appName := range *applicationData {
commentData := map[string]string{
"Authentication API Application Resource ID": appId,
"Authentication API Application Resource Name": appName,
"Resource Type": r.ResourceType(),
"Authentication API Application ID": appId,
"Authentication API Application Name": appName,
"Resource Type": r.ResourceType(),
}

importBlock := connector.ImportBlock{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (r *PingFederateAuthenticationPoliciesFragmentResource) ExportAll() (*[]con

for fragmentId, fragmentName := range *fragmentData {
commentData := map[string]string{
"Authentication Policies Fragment Resource ID": fragmentId,
"Authentication Policies Fragment Resource Name": fragmentName,
"Resource Type": r.ResourceType(),
"Authentication Policies Fragment ID": fragmentId,
"Authentication Policies Fragment Name": fragmentName,
"Resource Type": r.ResourceType(),
}

importBlock := connector.ImportBlock{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (r *PingFederateAuthenticationPolicyContractResource) ExportAll() (*[]conne

for authnPolicyContractId, authnPolicyContractName := range *authenticationPolicyContractData {
commentData := map[string]string{
"Authentication Policy Contract Resource ID": authnPolicyContractId,
"Authentication Policy Contract Resource Name": authnPolicyContractName,
"Resource Type": r.ResourceType(),
"Authentication Policy Contract ID": authnPolicyContractId,
"Authentication Policy Contract Name": authnPolicyContractName,
"Resource Type": r.ResourceType(),
}

importBlock := connector.ImportBlock{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (r *PingFederateAuthenticationSelectorResource) ExportAll() (*[]connector.I

for authnSelectorId, authnSelectorName := range *authenticationSelectorData {
commentData := map[string]string{
"Authentication Selector Resource ID": authnSelectorId,
"Authentication Selector Resource Name": authnSelectorName,
"Resource Type": r.ResourceType(),
"Authentication Selector ID": authnSelectorId,
"Authentication Selector Name": authnSelectorName,
"Resource Type": r.ResourceType(),
}

importBlock := connector.ImportBlock{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (r *PingFederateCaptchaProviderResource) ExportAll() (*[]connector.ImportBl

for captchaProviderId, captchaProviderName := range *captchaProviderData {
commentData := map[string]string{
"Captcha Provider Resource ID": captchaProviderId,
"Captcha Provider Resource Name": captchaProviderId,
"Resource Type": r.ResourceType(),
"Captcha Provider ID": captchaProviderId,
"Captcha Provider Name": captchaProviderId,
"Resource Type": r.ResourceType(),
}

importBlock := connector.ImportBlock{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (r *PingFederateCertificateCAResource) ExportAll() (*[]connector.ImportBloc

commentData := map[string]string{
"Certificate CA Issuer DN": certViewIssuerDN,
"Certificate CA Resource ID": certViewId,
"Certificate CA ID": certViewId,
"Certificate CA Serial Number": certViewSerialNumber,
"Resource Type": r.ResourceType(),
}
Expand Down Expand Up @@ -76,8 +76,8 @@ func (r *PingFederateCertificateCAResource) getTrustedCAData() (*map[string][]st
return nil, common.DataNilError(r.ResourceType(), response)
}

certViewsItems, ok := certViews.GetItemsOk()
if !ok {
certViewsItems, certViewsItemsOk := certViews.GetItemsOk()
if !certViewsItemsOk {
return nil, common.DataNilError(r.ResourceType(), response)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package resources

import (
"github.com/pingidentity/pingcli/internal/connector"
"github.com/pingidentity/pingcli/internal/connector/common"
"github.com/pingidentity/pingcli/internal/logger"
)

// Verify that the resource satisfies the exportable resource interface
var (
_ connector.ExportableResource = &PingFederateConfigurationEncryptionKeysRotateResource{}
)

type PingFederateConfigurationEncryptionKeysRotateResource struct {
clientInfo *connector.PingFederateClientInfo
}

// Utility method for creating a PingFederateConfigurationEncryptionKeysRotateResource
func ConfigurationEncryptionKeysRotate(clientInfo *connector.PingFederateClientInfo) *PingFederateConfigurationEncryptionKeysRotateResource {
return &PingFederateConfigurationEncryptionKeysRotateResource{
clientInfo: clientInfo,
}
}

func (r *PingFederateConfigurationEncryptionKeysRotateResource) ResourceType() string {
return "pingfederate_configuration_encryption_keys_rotate"
}

func (r *PingFederateConfigurationEncryptionKeysRotateResource) ExportAll() (*[]connector.ImportBlock, error) {
l := logger.Get()
l.Debug().Msgf("Exporting all '%s' Resources...", r.ResourceType())

importBlocks := []connector.ImportBlock{}

configurationEncryptionKeysRotateId := "configuration_encryption_keys_rotate_singleton_id"
configurationEncryptionKeysRotateName := "Configuration Encryption Keys Rotate"

commentData := map[string]string{
"Resource Type": r.ResourceType(),
"Singleton ID": common.SINGLETON_ID_COMMENT_DATA,
}

importBlock := connector.ImportBlock{
ResourceType: r.ResourceType(),
ResourceName: configurationEncryptionKeysRotateName,
ResourceID: configurationEncryptionKeysRotateId,
CommentInformation: common.GenerateCommentInformation(commentData),
}

importBlocks = append(importBlocks, importBlock)

return &importBlocks, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package resources_test

import (
"testing"

"github.com/pingidentity/pingcli/internal/connector"
"github.com/pingidentity/pingcli/internal/connector/pingfederate/resources"
"github.com/pingidentity/pingcli/internal/testing/testutils"
)

func TestPingFederateConfigurationEncryptionKeysRotateExport(t *testing.T) {
// Get initialized apiClient and resource
PingFederateClientInfo := testutils.GetPingFederateClientInfo(t)
resource := resources.ConfigurationEncryptionKeysRotate(PingFederateClientInfo)

// Defined the expected ImportBlocks for the resource
expectedImportBlocks := []connector.ImportBlock{
{
ResourceType: "pingfederate_configuration_encryption_keys_rotate",
ResourceName: "Configuration Encryption Keys Rotate",
ResourceID: "configuration_encryption_keys_rotate_singleton_id",
},
}

testutils.ValidateImportBlocks(t, resource, &expectedImportBlocks)
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func (r *PingFederateDataStoreResource) ExportAll() (*[]connector.ImportBlock, e

for dataStoreId, dataStoreType := range *dataStoreData {
commentData := map[string]string{
"Data Store Resource ID": dataStoreId,
"Data Store Type": dataStoreType,
"Resource Type": r.ResourceType(),
"Data Store ID": dataStoreId,
"Data Store Type": dataStoreType,
"Resource Type": r.ResourceType(),
}

importBlock := connector.ImportBlock{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package resources

import (
"github.com/pingidentity/pingcli/internal/connector"
"github.com/pingidentity/pingcli/internal/connector/common"
"github.com/pingidentity/pingcli/internal/logger"
)

// Verify that the resource satisfies the exportable resource interface
var (
_ connector.ExportableResource = &PingFederateIdentityStoreProvisionerResource{}
)

type PingFederateIdentityStoreProvisionerResource struct {
clientInfo *connector.PingFederateClientInfo
}

// Utility method for creating a PingFederateIdentityStoreProvisionerResource
func IdentityStoreProvisioner(clientInfo *connector.PingFederateClientInfo) *PingFederateIdentityStoreProvisionerResource {
return &PingFederateIdentityStoreProvisionerResource{
clientInfo: clientInfo,
}
}

func (r *PingFederateIdentityStoreProvisionerResource) ResourceType() string {
return "pingfederate_identity_store_provisioner"
}

func (r *PingFederateIdentityStoreProvisionerResource) ExportAll() (*[]connector.ImportBlock, error) {
l := logger.Get()
l.Debug().Msgf("Exporting all '%s' Resources...", r.ResourceType())

importBlocks := []connector.ImportBlock{}

identityStoreProvisionerData, err := r.getIdentityStoreProvisionerData()
if err != nil {
return nil, err
}

for identityStoreProvisionerId, identityStoreProvisionerName := range *identityStoreProvisionerData {
commentData := map[string]string{
"Identity Store Provisioner ID": identityStoreProvisionerId,
"Identity Store Provisioner Name": identityStoreProvisionerName,
"Resource Type": r.ResourceType(),
}

importBlock := connector.ImportBlock{
ResourceType: r.ResourceType(),
ResourceName: identityStoreProvisionerName,
ResourceID: identityStoreProvisionerId,
CommentInformation: common.GenerateCommentInformation(commentData),
}

importBlocks = append(importBlocks, importBlock)
}

return &importBlocks, nil
}

func (r *PingFederateIdentityStoreProvisionerResource) getIdentityStoreProvisionerData() (*map[string]string, error) {
identityStoreProvisionerData := make(map[string]string)

identityStoreProvisioners, response, err := r.clientInfo.ApiClient.IdentityStoreProvisionersAPI.GetIdentityStoreProvisioners(r.clientInfo.Context).Execute()
err = common.HandleClientResponse(response, err, "GetIdentityStoreProvisioners", r.ResourceType())
if err != nil {
return nil, err
}

if identityStoreProvisioners == nil {
return nil, common.DataNilError(r.ResourceType(), response)
}

identityStoreProvisionersItems, identityStoreProvisionersItemsOk := identityStoreProvisioners.GetItemsOk()
if !identityStoreProvisionersItemsOk {
return nil, common.DataNilError(r.ResourceType(), response)
}

for _, identityStoreProvisioner := range identityStoreProvisionersItems {
identityStoreProvisionerId, identityStoreProvisionerIdOk := identityStoreProvisioner.GetIdOk()
identityStoreProvisionerName, identityStoreProvisionerNameOk := identityStoreProvisioner.GetNameOk()

if identityStoreProvisionerIdOk && identityStoreProvisionerNameOk {
identityStoreProvisionerData[*identityStoreProvisionerId] = *identityStoreProvisionerName
}
}

return &identityStoreProvisionerData, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package resources_test

import (
"testing"

"github.com/pingidentity/pingcli/internal/connector"
"github.com/pingidentity/pingcli/internal/connector/pingfederate/resources"
"github.com/pingidentity/pingcli/internal/testing/testutils"
)

func TestPingFederateIdentityStoreProvisionerExport(t *testing.T) {
// Get initialized apiClient and resource
PingFederateClientInfo := testutils.GetPingFederateClientInfo(t)
resource := resources.IdentityStoreProvisioner(PingFederateClientInfo)

// Defined the expected ImportBlocks for the resource
expectedImportBlocks := []connector.ImportBlock{
{
ResourceType: "pingfederate_identity_store_provisioner",
ResourceName: "ISP TestName",
ResourceID: "ISPTestID",
},
}
testutils.ValidateImportBlocks(t, resource, &expectedImportBlocks)
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (r *PingFederateIDPAdapterResource) ExportAll() (*[]connector.ImportBlock,

for idpAdapterId, idpAdapterName := range *idpAdapterData {
commentData := map[string]string{
"IDP Adapter Resource ID": idpAdapterId,
"IDP Adapter Resource Name": idpAdapterName,
"Resource Type": r.ResourceType(),
"IDP Adapter ID": idpAdapterId,
"IDP Adapter Name": idpAdapterName,
"Resource Type": r.ResourceType(),
}

importBlock := connector.ImportBlock{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (r *PingFederateIDPSPConnectionResource) ExportAll() (*[]connector.ImportBl

for spConnectionId, spConnectionName := range *spConnectionData {
commentData := map[string]string{
"IDP SP Connection Resource ID": spConnectionId,
"IDP SP Connection Resource Name": spConnectionName,
"Resource Type": r.ResourceType(),
"IDP SP Connection ID": spConnectionId,
"IDP SP Connection Name": spConnectionName,
"Resource Type": r.ResourceType(),
}

importBlock := connector.ImportBlock{
Expand Down
Loading