Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4d46447
CDI-412: Add Copyright Headers to Golang Files
erikostien-pingidentity Mar 19, 2025
f191941
WIP
erikostien-pingidentity Mar 20, 2025
589e83c
Code gen and testable resources for pingone-management complete
erikostien-pingidentity Mar 21, 2025
16d7ef5
Add PingOne SSO generated code and testable resources
erikostien-pingidentity Mar 25, 2025
b57f0de
Fix testing fatal to error so deferred cleanup functions can run. Fix…
erikostien-pingidentity Mar 25, 2025
3138827
Add generated code for MFA and Protect resources as well as testable …
erikostien-pingidentity Mar 25, 2025
3196afa
Add PingOne Authorize code generation and testable resources
erikostien-pingidentity Mar 27, 2025
5c12eb0
Use developer independent testing env vars
erikostien-pingidentity Mar 27, 2025
32976a4
Update testing to be developer independent
erikostien-pingidentity Mar 27, 2025
d7560fc
Merge branch 'main' into CDI-412
erikostien-pingidentity Mar 27, 2025
234d58a
Upgrade dependencies
erikostien-pingidentity Mar 27, 2025
4779e20
Update golangci/golangci-lint-action to v7
erikostien-pingidentity Mar 27, 2025
db58568
golangci-lint fixes
erikostien-pingidentity Mar 27, 2025
7043e4e
Switch golang config file to enabled linters
erikostien-pingidentity Mar 27, 2025
c90059d
Update PF container variable injection
erikostien-pingidentity Mar 27, 2025
c9a92f8
Update PF container variable injection
erikostien-pingidentity Mar 27, 2025
5163dff
Test fixes and code review changes
erikostien-pingidentity Mar 28, 2025
2aaed09
More testing fixes
erikostien-pingidentity Mar 28, 2025
f6adf15
Disable sign-on policy tests for TRIAGE-26632
erikostien-pingidentity Mar 28, 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
  •  
  •  
  •  
32 changes: 9 additions & 23 deletions .github/workflows/code-analysis-lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
go-version-file: "go.mod"
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
Expand Down Expand Up @@ -123,30 +123,16 @@ jobs:
needs: [build]
runs-on: ubuntu-latest
env:
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 }}
PINGCLI_PINGONE_WORKER_ENVIRONMENT_ID: ${{ secrets.PINGCLI_PINGONE_WORKER_ENVIRONMENT_ID }}
PINGCLI_PINGONE_EXPORT_ENVIRONMENT_ID: ${{ secrets.PINGCLI_PINGONE_EXPORT_ENVIRONMENT_ID }}
PINGONE_CLIENT_ID: ${{ secrets.PINGONE_CLIENT_ID }}
PINGONE_CLIENT_SECRET: ${{ secrets.PINGONE_CLIENT_SECRET }}
PINGONE_ENVIRONMENT_ID: ${{ secrets.PINGONE_ENVIRONMENT_ID }}
PINGONE_REGION_CODE: ${{ secrets.PINGONE_REGION_CODE }}
PINGCLI_LOG_LEVEL: ${{ vars.PINGCLI_LOG_LEVEL }}
PINGCLI_LOG_PATH: ${{ vars.PINGCLI_LOG_PATH }}
PINGCLI_PINGONE_PROVIDER_VERSION: ${{ vars.PINGCLI_PINGONE_PROVIDER_VERSION }}
PINGCLI_PINGFEDERATE_ADMIN_API_PATH: ${{ secrets.PINGCLI_PINGFEDERATE_ADMIN_API_PATH }}
PINGCLI_PINGFEDERATE_CLIENT_ID: ${{ secrets.PINGCLI_PINGFEDERATE_CLIENT_ID }}
PINGCLI_PINGFEDERATE_CLIENT_SECRET: ${{ secrets.PINGCLI_PINGFEDERATE_CLIENT_SECRET }}
PINGCLI_PINGFEDERATE_HTTPS_HOST: ${{ secrets.PINGCLI_PINGFEDERATE_HTTPS_HOST }}
PINGCLI_PINGFEDERATE_PASSWORD: ${{ secrets.PINGCLI_PINGFEDERATE_PASSWORD }}
PINGCLI_PINGFEDERATE_SCOPES: ${{ secrets.PINGCLI_PINGFEDERATE_SCOPES }}
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 }}
TEST_PING_IDENTITY_ACCEPT_EULA: ${{ vars.TEST_PING_IDENTITY_ACCEPT_EULA }}
TEST_PING_IDENTITY_DEVOPS_USER: ${{ secrets.TEST_PING_IDENTITY_DEVOPS_USER }}
TEST_PING_IDENTITY_DEVOPS_KEY: ${{ secrets.TEST_PING_IDENTITY_DEVOPS_KEY }}
TEST_PINGONE_ENVIRONMENT_ID: ${{ secrets.TEST_PINGONE_ENVIRONMENT_ID }}
TEST_PINGONE_WORKER_CLIENT_ID: ${{ secrets.TEST_PINGONE_WORKER_CLIENT_ID }}
TEST_PINGONE_WORKER_CLIENT_SECRET: ${{ secrets.TEST_PINGONE_WORKER_CLIENT_SECRET }}
TEST_PINGONE_REGION_CODE: ${{ secrets.TEST_PINGONE_REGION_CODE }}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand Down
70 changes: 65 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,68 @@
# Options for analysis running.
run:
timeout: 30m

# Use all default linters + those defined here
version: "2"
linters:
enable:
- asasalint
- asciicheck
- bidichk
- canonicalheader
- copyloopvar
- decorder
- dogsled
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exptostd
- forcetypeassert
- ginkgolinter
- gocheckcompilerdirectives
- gochecksumtype
- gocritic
- goheader
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosmopolitan
- govet
- grouper
- iface
- importas
- inamedparam
- ineffassign
- interfacebloat
- intrange
- ireturn
- makezero
- mirror
- misspell
- musttag
- nakedret
- nilerr
- nilnesserr
- nilnil
- nlreturn
- noctx
- nolintlint
- nosprintfhostport
- prealloc
- predeclared
- protogetter
- reassign
- rowserrcheck
- staticcheck
- tagalign
- testableexamples
- testpackage
- thelper
- tparallel
- unconvert
- unparam
- unused
- usestdlibvars
- usetesting
- wastedassign
- whitespace
- zerologlint
47 changes: 29 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ vet:
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: --checktestenvvars --test-cmd --test-internal-commands --test-internal-configuration --test-internal-connector --test-internal-customtypes --test-internal-input --test-internal-profiles

--checktestenvvars:
@echo -n "Checking for required environment variables to run pingcli tests..."
@test -n "$$TEST_PINGONE_ENVIRONMENT_ID" || { echo " FAILED"; echo "TEST_PINGONE_ENVIRONMENT_ID environment variable is not set.\n\nCreate/Specify an unconfigured PingOne environment to test PingCLI with. The following services are required: PingOne SSO, PingOne MFA, PingOne Protect, PingOne DaVinci, PingOne Authorize, and PingFederate"; exit 1; }
@test -n "$$TEST_PINGONE_REGION_CODE" || { echo " FAILED"; echo "TEST_PINGONE_REGION_CODE environment variable is not set.\n\nCreate/Specify an unconfigured PingOne environment to test PingCLI with. The following services are required: PingOne SSO, PingOne MFA, PingOne Protect, PingOne DaVinci, PingOne Authorize, and PingFederate"; exit 1; }
@test -n "$$TEST_PINGONE_WORKER_CLIENT_ID" || { echo " FAILED"; echo "TEST_PINGONE_WORKER_CLIENT_ID environment variable is not set.\n\nCreate/Specify a worker applicaiton in the unconfigured PingOne environment with all admin roles to test PingCLI with"; exit 1; }
@test -n "$$TEST_PINGONE_WORKER_CLIENT_SECRET" || { echo " FAILED"; echo "TEST_PINGONE_WORKER_CLIENT_SECRET environment variable is not set.\n\nCreate/Specify a worker applicaiton in an unconfigured PingOne environment with all admin roles to test PingCLI with"; exit 1; }
@echo " SUCCESS"

--test-cmd:
@echo "Running tests for cmd..."
Expand All @@ -61,11 +69,19 @@ test: --test-cmd --test-internal-commands --test-internal-configuration --test-i

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

@# Test the connectors itegration terraform plan tests
@go test -count=1 ./internal/connector/pingfederate
@go test -count=1 ./internal/connector/pingone/*/
@go test -count=1 ./internal/connector/pingone/authorize
@go test -count=1 ./internal/connector/pingone/mfa
@go test -count=1 ./internal/connector/pingone/platform
@go test -count=1 ./internal/connector/pingone/protect
@go test -count=1 ./internal/connector/pingone/sso

--test-internal-customtypes:
@echo "Running tests for internal/customtypes..."
Expand Down Expand Up @@ -93,22 +109,17 @@ importfmtlint:
fi

golangcilint:
@echo -n "Running 'golangci-lint' to check for code quality issues..."
@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 clean && golangci-lint run --timeout 5m ./...; then \
echo " SUCCESS"; \
else \
echo " FAILED"; \
exit 1; \
fi
@golangci-lint cache clean && golangci-lint run --timeout 5m ./...

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

--checkneededpfenvvars:
--checkpfcontainerenvvars:
@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; }
@test -n "$$TEST_PING_IDENTITY_DEVOPS_USER" || { echo " FAILED"; echo "TEST_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 "$$TEST_PING_IDENTITY_DEVOPS_KEY" || { echo " FAILED"; echo "TEST_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" = "$$TEST_PING_IDENTITY_ACCEPT_EULA" || { echo " FAILED"; echo "You must accept the EULA to use the PingFederate container. Set TEST_PING_IDENTITY_ACCEPT_EULA=YES to continue."; exit 1; }
@echo " SUCCESS"

--checkdocker:
Expand All @@ -121,9 +132,9 @@ starttestcontainer: --checkneededpfenvvars --checkdocker --dockerrunpf --waitfor
@docker run --name pingcli_test_pingfederate_container \
-d -p 9031:9031 \
-p 9999:9999 \
--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 PING_IDENTITY_DEVOPS_USER="$${TEST_PING_IDENTITY_DEVOPS_USER}" \
--env PING_IDENTITY_DEVOPS_KEY="$${TEST_PING_IDENTITY_DEVOPS_KEY}" \
--env PING_IDENTITY_ACCEPT_EULA="$${TEST_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; }
Expand Down
8 changes: 5 additions & 3 deletions cmd/common/cobra_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ func ExactArgs(numArgs int) cobra.PositionalArgs {
if len(args) != numArgs {
return fmt.Errorf("failed to execute '%s': command accepts %d arg(s), received %d", cmd.CommandPath(), numArgs, len(args))
}

return nil
}
}

func RangeArgs(min, max int) cobra.PositionalArgs {
func RangeArgs(minArgs, maxArgs int) cobra.PositionalArgs {
return func(cmd *cobra.Command, args []string) error {
if len(args) < min || len(args) > max {
return fmt.Errorf("failed to execute '%s': command accepts %d to %d arg(s), received %d", cmd.CommandPath(), min, max, len(args))
if len(args) < minArgs || len(args) > maxArgs {
return fmt.Errorf("failed to execute '%s': command accepts %d to %d arg(s), received %d", cmd.CommandPath(), minArgs, maxArgs, len(args))
}

return nil
}
}
1 change: 1 addition & 0 deletions cmd/completion/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@ func Command() *cobra.Command {
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
RunE: completionCmdRunE,
}

return cmd
}
12 changes: 8 additions & 4 deletions cmd/config/unset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
package config_test

import (
"os"
"testing"

"github.com/pingidentity/pingcli/internal/configuration/options"
"github.com/pingidentity/pingcli/internal/profiles"
"github.com/pingidentity/pingcli/internal/testing/testutils"
"github.com/pingidentity/pingcli/internal/testing/testutils_cobra"
"github.com/pingidentity/pingcli/internal/testing/testutils_viper"
)

// Test Config Unset Command Executes without issue
Expand Down Expand Up @@ -41,15 +41,19 @@ func TestConfigUnsetCmd_InvalidKey(t *testing.T) {

// Test Config Unset Command for key 'pingone.worker.clientId' updates viper configuration
func TestConfigUnsetCmd_CheckViperConfig(t *testing.T) {
testutils_viper.InitVipers(t)

mainViper := profiles.GetMainConfig().ViperInstance()
viperKey := options.PingOneAuthenticationWorkerClientIDOption.ViperKey
viperOldValue := os.Getenv(options.PingOneAuthenticationWorkerClientIDOption.EnvVar)
profileViperKey := "default." + viperKey

viperOldValue := mainViper.GetString(profileViperKey)

err := testutils_cobra.ExecutePingcli(t, "config", "unset", viperKey)
testutils.CheckExpectedError(t, err, nil)

mainViper := profiles.GetMainConfig().ViperInstance()
profileViperKey := "default." + viperKey
viperNewValue := mainViper.GetString(profileViperKey)

if viperOldValue == viperNewValue {
t.Errorf("Expected viper configuration value to be updated. Old: %s, New: %s", viperOldValue, viperNewValue)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/platform/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ func initPingOneExportFlags(cmd *cobra.Command) {
options.PingOneAuthenticationWorkerClientSecretOption.CobraParamName,
options.PingOneRegionCodeOption.CobraParamName,
)

}

func initPingFederateGeneralFlags(cmd *cobra.Command) {
Expand Down
Loading