Skip to content

Commit

Permalink
PDI-1813: Export block HCL generation for PingFederate (#127)
Browse files Browse the repository at this point in the history
- Update Option Objects variable names to contain the service name to
distinguish between PingOne options and PingFederate Options.
- Update Cobra Subcommand `platform export` to support the new export
service PingFederate. Add additional examples for PingFederate export
parameters. Break out cobra flag configuration by service, and add
PingFederate flags. Mark each PingFederate Auth method as mutually
exclusive for the user to avoid authentication confusion.
- Update cobra root command root.go to fail if the user provided config file
does not exist.
- Add profile config enum type ENUM_STRING_SLICE for PF scopes and
PF pem files. Support these slices in set_internal.go and validate.go.
- Update export_internal.go to initialize both PingOne go client and
PingFederate go client when needed. Update getExportableConnectors
to use instance variables depending on the service connector specified.
- Break out SDKClientInfo into PingOneClientInfo and PingFederateClientInfo
for different services.
- Create pingfederate_connector.go to export PF API resources.
- Add first PF resource for export, pingfederate_authentication_api_application.go
- Add server-profiles directory to hold PingFederate server-profile for
container starting and testing.
  • Loading branch information
erikostien-pingidentity authored Aug 16, 2024
1 parent b1322d7 commit 657656e
Show file tree
Hide file tree
Showing 167 changed files with 6,879 additions and 843 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/code-analysis-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ jobs:
needs: [build]
runs-on: ubuntu-latest
env:
PING_IDENTITY_CONFIG: ${{ secrets.PING_IDENTITY_CONFIG }}
PINGCTL_PINGONE_WORKER_CLIENT_ID: ${{ secrets.PINGCTL_PINGONE_WORKER_CLIENT_ID }}
PINGCTL_PINGONE_WORKER_CLIENT_SECRET: ${{ secrets.PINGCTL_PINGONE_WORKER_CLIENT_SECRET }}
PINGCTL_PINGONE_REGION: ${{ secrets.PINGCTL_PINGONE_REGION }}
Expand All @@ -134,6 +135,15 @@ jobs:
PINGCTL_LOG_LEVEL: ${{ vars.PINGCTL_LOG_LEVEL }}
PINGCTL_LOG_PATH: ${{ vars.PINGCTL_LOG_PATH }}
PINGCTL_PINGONE_PROVIDER_VERSION: ${{ vars.PINGCTL_PINGONE_PROVIDER_VERSION }}
PINGCTL_PINGFEDERATE_ADMIN_API_PATH: ${{ secrets.PINGCTL_PINGFEDERATE_ADMIN_API_PATH }}
PINGCTL_PINGFEDERATE_CLIENT_ID: ${{ secrets.PINGCTL_PINGFEDERATE_CLIENT_ID }}
PINGCTL_PINGFEDERATE_CLIENT_SECRET: ${{ secrets.PINGCTL_PINGFEDERATE_CLIENT_SECRET }}
PINGCTL_PINGFEDERATE_HTTPS_HOST: ${{ secrets.PINGCTL_PINGFEDERATE_HTTPS_HOST }}
PINGCTL_PINGFEDERATE_PASSWORD: ${{ secrets.PINGCTL_PINGFEDERATE_PASSWORD }}
PINGCTL_PINGFEDERATE_SCOPES: ${{ secrets.PINGCTL_PINGFEDERATE_SCOPES }}
PINGCTL_PINGFEDERATE_TOKEN_URL: ${{ secrets.PINGCTL_PINGFEDERATE_TOKEN_URL }}
PINGCTL_PINGFEDERATE_USERNAME: ${{ secrets.PINGCTL_PINGFEDERATE_USERNAME }}
PINGCTL_PINGFEDERATE_PROVIDER_VERSION: ${{ vars.PINGCTL_PINGFEDERATE_PROVIDER_VERSION }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand All @@ -143,4 +153,4 @@ jobs:
- uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false
- run: make test
- run: mkdir -p $HOME/.pingidentity/ && echo "$PING_IDENTITY_CONFIG" >> $HOME/.pingidentity/config && grep -E "[a-zA-Z]" $HOME/.pingidentity/config || exit 1 && make starttestcontainer && make test && make removetestcontainer
33 changes: 32 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,41 @@ test:

devchecknotest: install importfmtlint fmt vet golangcilint

devcheck: devchecknotest test
devcheck: devchecknotest spincontainer test removetestcontainer

importfmtlint:
go run github.com/pavius/impi/cmd/impi --local . --scheme stdThirdPartyLocal ./...

golangcilint:
go run github.com/golangci/golangci-lint/cmd/golangci-lint run --timeout 5m ./...

starttestcontainer:
docker run --name pingfederate_terraform_provider_container \
-d -p 9031:9031 \
-p 9999:9999 \
--env-file "${HOME}/.pingidentity/config" \
-v $$(pwd)/server-profiles/shared-profile:/opt/in \
-v $$(pwd)/server-profiles/12.1/data.json.subst:/opt/in/instance/bulk-config/data.json.subst \
pingidentity/pingfederate:latest
# Wait for the instance to become ready
sleep 1
duration=0
while (( duration < 240 )) && ! docker logs pingfederate_terraform_provider_container 2>&1 | grep -q "Removing Imported Bulk File\|CONTAINER FAILURE"; \
do \
duration=$$((duration+1)); \
sleep 1; \
done
# Fail if the container didn't become ready in time
docker logs pingfederate_terraform_provider_container 2>&1 | grep -q "Removing Imported Bulk File" || \
{ echo "PingFederate container did not become ready in time or contains errors. Logs:"; docker logs pingfederate_terraform_provider_container; exit 1; }

removetestcontainer:
docker rm -f pingfederate_terraform_provider_container

spincontainer: removetestcontainer starttestcontainer

openlocalwebapi:
open "https://localhost:9999/pf-admin-api/api-docs/#/"

openapp:
open "https://localhost:9999/pingfederate/app"
2 changes: 1 addition & 1 deletion cmd/config/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestConfigGetCmd_TooManyArgs(t *testing.T) {

// Test Config Get Command Executes when provided a full key
func TestConfigGetCmd_FullKey(t *testing.T) {
err := testutils_cobra.ExecutePingctl(t, "config", "get", profiles.WorkerClientIDOption.ViperKey)
err := testutils_cobra.ExecutePingctl(t, "config", "get", profiles.PingOneWorkerClientIDOption.ViperKey)
testutils.CheckExpectedError(t, err, nil)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/config/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestConfigSetCmd_NoValueProvided(t *testing.T) {

// Test Config Set Command for key 'pingone.worker.clientId' updates viper configuration
func TestConfigSetCmd_CheckViperConfig(t *testing.T) {
viperKey := profiles.WorkerClientIDOption.ViperKey
viperKey := profiles.PingOneWorkerClientIDOption.ViperKey
viperNewUUID := "12345678-1234-1234-1234-123456789012"

err := testutils_cobra.ExecutePingctl(t, "config", "set", fmt.Sprintf("%s=%s", viperKey, viperNewUUID))
Expand Down
4 changes: 2 additions & 2 deletions cmd/config/unset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func TestConfigUnsetCmd_InvalidKey(t *testing.T) {

// Test Config Unset Command for key 'pingone.worker.clientId' updates viper configuration
func TestConfigUnsetCmd_CheckViperConfig(t *testing.T) {
viperKey := profiles.WorkerClientIDOption.ViperKey
viperOldValue := os.Getenv(profiles.WorkerClientIDOption.EnvVar)
viperKey := profiles.PingOneWorkerClientIDOption.ViperKey
viperOldValue := os.Getenv(profiles.PingOneWorkerClientIDOption.EnvVar)

err := testutils_cobra.ExecutePingctl(t, "config", "unset", viperKey)
testutils.CheckExpectedError(t, err, nil)
Expand Down
Loading

0 comments on commit 657656e

Please sign in to comment.