Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
15abe57
Use code generation for pingfederate_authentication_api_application r…
erikostien-pingidentity Jan 15, 2025
82127c7
Use code generation for pingfederate_authentication_api_settings reso…
erikostien-pingidentity Jan 15, 2025
7c2d4b9
Update pingfederate_authentication_policies_fragment, pingfederate_au…
erikostien-pingidentity Jan 16, 2025
e2573de
Update pingfederate_authentication_policy_contract to use code gen
erikostien-pingidentity Jan 16, 2025
3af1599
Update pingfederate_authentication_selector to use code gen
erikostien-pingidentity Jan 16, 2025
e4dce0c
Update pingfederate_captcha_provider_settings to use code gen
erikostien-pingidentity Jan 16, 2025
3a9fec0
Update pingfederate_captcha_provider to use code gen
erikostien-pingidentity Jan 16, 2025
380ba68
Update pingfederate_certificate_ca to use code gen
erikostien-pingidentity Jan 16, 2025
7fc8cad
Update pingfederate_certificates_revocation_ocsp_certificate to use c…
erikostien-pingidentity Jan 16, 2025
5abfa5c
Update pingfederate_certificates_revocation_settings to use code gen
erikostien-pingidentity Jan 16, 2025
24391be
Update pingfederate_cluster_settings to use code gen
erikostien-pingidentity Jan 16, 2025
f38f32f
Update pingfederate_configuration_encryption_keys_rotate to use code gen
erikostien-pingidentity Jan 16, 2025
b3fea4a
Update pingfederate_data_store to use code gen
erikostien-pingidentity Jan 16, 2025
fcea5fc
Code Generate All PingFederate Resource Export Logic and Testing
erikostien-pingidentity Jan 23, 2025
6190bba
Update all unit tests for PingFederate export
erikostien-pingidentity Jan 23, 2025
c10612c
First steps of testable resources
erikostien-pingidentity Jan 30, 2025
3c5ef7f
Merge branch 'main' into PDI-2063
erikostien-pingidentity Feb 6, 2025
7b5d99a
WIP independent developer resource export testing
erikostien-pingidentity Mar 6, 2025
dc975b8
WIP
erikostien-pingidentity Mar 14, 2025
9845ac5
Merge branch 'main' into PDI-2063
erikostien-pingidentity Mar 14, 2025
d411b15
WIP
erikostien-pingidentity Mar 14, 2025
d8474d7
Lint fixes
erikostien-pingidentity Mar 14, 2025
0bdd673
Lint fixes
erikostien-pingidentity Mar 14, 2025
9ad1d52
WIP
erikostien-pingidentity Mar 16, 2025
7e93381
WIP
erikostien-pingidentity Mar 16, 2025
7889c04
Update Deps
erikostien-pingidentity Mar 17, 2025
3c2d5bd
WIP
erikostien-pingidentity Mar 17, 2025
07f8878
Add integration tests back
erikostien-pingidentity Mar 17, 2025
c353c4f
Don't change goreleaser
erikostien-pingidentity Mar 17, 2025
2da6961
Do not replace patrickcping/pingone-go-sdk-v2/management in go.mod
erikostien-pingidentity Mar 17, 2025
369c59e
Update github actions env vars
erikostien-pingidentity Mar 17, 2025
6112bc9
PR review changes
erikostien-pingidentity Mar 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions .github/workflows/code-analysis-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ jobs:
needs: [build]
runs-on: ubuntu-latest
env:
PING_IDENTITY_CONFIG: ${{ secrets.PING_IDENTITY_CONFIG }}
PINGCLI_PINGONE_WORKER_CLIENT_ID: ${{ secrets.PINGCLI_PINGONE_WORKER_CLIENT_ID }}
PINGCLI_PINGONE_WORKER_CLIENT_SECRET: ${{ secrets.PINGCLI_PINGONE_WORKER_CLIENT_SECRET }}
PINGCLI_PINGONE_REGION_CODE: ${{ secrets.PINGCLI_PINGONE_REGION_CODE }}
Expand All @@ -145,6 +144,9 @@ jobs:
PINGCLI_PINGFEDERATE_TOKEN_URL: ${{ secrets.PINGCLI_PINGFEDERATE_TOKEN_URL }}
PINGCLI_PINGFEDERATE_USERNAME: ${{ secrets.PINGCLI_PINGFEDERATE_USERNAME }}
PINGCLI_PINGFEDERATE_PROVIDER_VERSION: ${{ vars.PINGCLI_PINGFEDERATE_PROVIDER_VERSION }}
PING_IDENTITY_DEVOPS_USER: ${{ secrets.PING_IDENTITY_DEVOPS_USER }}
PING_IDENTITY_DEVOPS_KEY: ${{ secrets.PING_IDENTITY_DEVOPS_KEY }}
PING_IDENTITY_ACCEPT_EULA: ${{ vars.PING_IDENTITY_ACCEPT_EULA }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand All @@ -154,4 +156,4 @@ jobs:
- uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false
- 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
- run: make starttestcontainer && make test && make removetestcontainer
176 changes: 147 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,59 +1,177 @@
SHELL := /bin/bash

.PHONY: install fmt vet test devchecknotest devcheck importfmtlint
.PHONY: install fmt vet test devchecknotest devcheck importfmtlint golangcilint starttestcontainer removetestcontainer spincontainer openlocalwebapi openapp

default: install

install:
go mod tidy
go install .
@echo -n "Running 'go mod tidy' to ensure all dependencies are up to date..."
@if go mod tidy; then \
echo " SUCCESS"; \
else \
echo " FAILED"; \
exit 1; \
fi

@echo -n "Running 'go install' to install pingcli..."
@if go install .; then \
echo " SUCCESS"; \
else \
echo " FAILED"; \
exit 1; \
fi

fmt:
go fmt ./...
@echo -n "Running 'go fmt' to format the code..."
@if go fmt ./...; then \
echo " SUCCESS"; \
else \
echo " FAILED"; \
exit 1; \
fi

vet:
go vet ./...
@echo -n "Running 'go vet' to check for potential issues..."
@if go vet ./...; then \
echo " SUCCESS"; \
else \
echo " FAILED"; \
exit 1; \
fi

test: --test-cmd --test-internal-commands --test-internal-configuration --test-internal-connector --test-internal-customtypes --test-internal-input --test-internal-profiles

--test-cmd:
@echo "Running tests for cmd..."
@go test -count=1 ./cmd/...

--test-internal-commands:
@echo "Running tests for internal/commands..."
@go test -count=1 ./internal/commands/...

--test-internal-configuration:
@echo "Running tests for internal/configuration..."
@go test -count=1 ./internal/configuration/...

--test-internal-connector:
@echo "Running tests for internal/connector..."

@# Test each connector package separately to avoid configuration collision
@go test -count=1 ./internal/connector

@# Test the resources within each connector first
@go test -count=1 ./internal/connector/pingfederate/resources
@go test -count=1 ./internal/connector/pingone/.../resources

test:
go test -parallel=4 -count=1 ./...
@# Test the connectors itegration terraform plan tests
@go test -count=1 ./internal/connector/pingfederate
@go test -count=1 ./internal/connector/pingone/*/

--test-internal-customtypes:
@echo "Running tests for internal/customtypes..."
@go test -count=1 ./internal/customtypes/...

--test-internal-input:
@echo "Running tests for internal/input..."
@go test -count=1 ./internal/input/...

--test-internal-profiles:
@echo "Running tests for internal/profiles..."
@go test -count=1 ./internal/profiles/...

devchecknotest: install importfmtlint fmt vet golangcilint

devcheck: devchecknotest spincontainer test removetestcontainer

importfmtlint:
impi --local . --scheme stdThirdPartyLocal ./...
@echo -n "Running 'impi' to format import ordering..."
@if impi --local . --scheme stdThirdPartyLocal ./...; then \
echo " SUCCESS"; \
else \
echo " FAILED"; \
exit 1; \
fi

golangcilint:
golangci-lint run --timeout 5m ./...
@echo -n "Running 'golangci-lint' to check for code quality issues..."
@# Clear the cache for every run, so that the linter outputs the same results as the GH Actions workflow
@if golangci-lint cache clear && golangci-lint run --timeout 5m ./...; then \
echo " SUCCESS"; \
else \
echo " FAILED"; \
exit 1; \
fi

starttestcontainer: --checkneededpfenvvars --checkdocker --dockerrunpf --waitforpfhealthy

starttestcontainer:
docker run --name pingfederate_terraform_provider_container \
--checkneededpfenvvars:
@echo -n "Checking for required environment variables to run PingFederate container..."
@test -n "$$PING_IDENTITY_DEVOPS_USER" || { echo " FAILED"; echo "PING_IDENTITY_DEVOPS_USER environment variable is not set.\n\nNot Registered? Register for the DevOps Program at https://devops.pingidentity.com/how-to/devopsRegistration/."; exit 1; }
@test -n "$$PING_IDENTITY_DEVOPS_KEY" || { echo " FAILED"; echo "PING_IDENTITY_DEVOPS_KEY environment variable is not set.\n\nNot Registered? Register for the DevOps Program at https://devops.pingidentity.com/how-to/devopsRegistration/."; exit 1; }
@test "YES" = "$$PING_IDENTITY_ACCEPT_EULA" || { echo " FAILED"; echo "You must accept the EULA to use the PingFederate container. Set PING_IDENTITY_ACCEPT_EULA=YES to continue."; exit 1; }
@echo " SUCCESS"

--checkdocker:
@echo -n "Checking if Docker is running..."
@docker info > /dev/null 2>&1 || { echo " FAILED"; echo "Docker is not running. Please start Docker and try again."; exit 1; }
@echo " SUCCESS"

--dockerrunpf:
@echo -n "Starting the PingFederate container..."
@docker run --name pingcli_test_pingfederate_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.2/data.json:/opt/in/instance/bulk-config/data.json \
pingidentity/pingfederate:12.2.0-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)); \
--env PING_IDENTITY_DEVOPS_USER="$${PING_IDENTITY_DEVOPS_USER}" \
--env PING_IDENTITY_DEVOPS_KEY="$${PING_IDENTITY_DEVOPS_KEY}" \
--env PING_IDENTITY_ACCEPT_EULA="$${PING_IDENTITY_ACCEPT_EULA}" \
--env CREATE_INITIAL_ADMIN_USER="true" \
-v $$(pwd)/internal/testing/pingfederate_container_files/deploy:/opt/in/instance/server/default/deploy \
pingidentity/pingfederate:latest > /dev/null 2>&1 || { echo " FAILED"; echo "Failed to start the PingFederate container. Please check your Docker setup."; exit 1; }
@echo " SUCCESS"

--waitforpfhealthy:
@echo -n "Waiting for the PingFederate container to become healthy..."
@timeout=240; \
while test $$timeout -gt 0; do \
status=$$(docker inspect --format='{{json .State.Health.Status}}' pingcli_test_pingfederate_container 2>/dev/null || echo ""); \
if test "$$status" = '"healthy"'; then \
echo " SUCCESS"; \
exit 0; \
fi; \
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; }
timeout=$$((timeout - 1)); \
done; \
echo " FAILED"; \
echo "PingFederate container did not become healthy within the timeout period."; \
echo "Current status: $$status"; \
docker logs pingcli_test_pingfederate_container || echo "No logs available."; \
exit 1

removetestcontainer:
docker rm -f pingfederate_terraform_provider_container
removetestcontainer: --checkdocker
@echo -n "Stopping and removing the PingFederate container..."
@if docker rm -f pingcli_test_pingfederate_container > /dev/null 2>&1; then \
echo " SUCCESS"; \
else \
echo " FAILED"; \
exit 1; \
fi

spincontainer: removetestcontainer starttestcontainer

openlocalwebapi:
open "https://localhost:9999/pf-admin-api/api-docs/#/"
@echo -n "Opening the PingFederate Admin API documentation in the default web browser..."
@if open "https://localhost:9999/pf-admin-api/api-docs/#/"; then \
echo " SUCCESS"; \
else \
echo " FAILED"; \
exit 1; \
fi

openapp:
open "https://localhost:9999/pingfederate/app"
@echo -n "Opening the PingFederate Admin Console in the default web browser..."
@if open "https://localhost:9999/pingfederate/app"; then \
echo " SUCCESS"; \
else \
echo " FAILED"; \
exit 1; \
fi
6 changes: 3 additions & 3 deletions cmd/config/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ func Example_getEmptyMaskedValue() {
// https://pkg.go.dev/testing#hdr-Examples
func Example_getMaskedValue() {
t := testing.T{}
_ = testutils_cobra.ExecutePingcli(&t, "config", "get", options.PingFederateClientCredentialsAuthClientSecretOption.ViperKey)
_ = testutils_cobra.ExecutePingcli(&t, "config", "get", options.PingFederateBasicAuthPasswordOption.ViperKey)

// Output:
// Configuration values for profile 'default' and key 'service.pingfederate.authentication.clientCredentialsAuth.clientSecret':
// service.pingfederate.authentication.clientCredentialsAuth.clientSecret=********
// Configuration values for profile 'default' and key 'service.pingfederate.authentication.basicAuth.password':
// service.pingfederate.authentication.basicAuth.password=********
}

// https://pkg.go.dev/testing#hdr-Examples
Expand Down
Loading