Skip to content
Draft
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
6 changes: 4 additions & 2 deletions .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ on:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.golangci.yml'
- '.github/workflows/go-lint.yml'
pull_request:
branches: [ main ]
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.golangci.yml'
- '.github/workflows/go-lint.yml'

jobs:
Expand All @@ -33,5 +35,5 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: latest
args: --timeout=5m
version: v2.6.1
args: --config=.golangci.yml --timeout=5m
102 changes: 102 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# golangci-lint configuration file
# This ensures consistent linting behavior locally and in CI/CD

# Defines the configuration version. The only possible value is "2".
version: "2"

run:
timeout: 5m
tests: true
# Include test files in linting
build-tags:
- integration

linters:
enable:
# Enabled by default
- errcheck # Check for unchecked errors
- govet # Reports suspicious constructs
- ineffassign # Detect ineffectual assignments
- staticcheck # Advanced Go linter
- unused # Check for unused code

# Additional recommended linters for SDK quality
- misspell # Find commonly misspelled words
- revive # Fast, configurable linter
- unconvert # Remove unnecessary type conversions

disable:
# Disabled to avoid noise - can be enabled selectively later
- exhaustruct # Too strict for test structs
- funlen # Function length checks can be too strict
- nlreturn # Newline return can be stylistic
- paralleltest # Not all tests need to be parallel
- wsl # Whitespace linter can be too opinionated
- testifylint # Can be overly strict about testify usage

# v2 schema exclusions are defined here, not under 'issues'
exclusions:
# Replaces 'issues.exclude-dirs' and 'issues.exclude-files'
paths:
- vendor/ # Exclude the vendor directory
- "pingone/.*\\.go$" # Exclude generated code in pingone directory

# Replaces 'issues.exclude-rules'
rules:
# Exclude some linters from running on tests files
- path: _test\.go
linters:
- gocyclo
- dupl
- gosec
- goconst

settings:
errcheck:
check-type-assertions: true
check-blank: false

govet:
enable-all: true
disable:
- shadow # Can be overly strict
- fieldalignment # Optimization suggestion, not a bug

staticcheck:
checks: ["all"]

misspell:
locale: US

revive:
confidence: 0.8
rules:
- name: blank-imports
- name: context-as-argument
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: package-comments
- name: range
- name: receiver-naming
- name: indent-error-flow
- name: superfluous-else
- name: unreachable-code
- name: unused-parameter

issues:
# Exclude keys moved to 'linters.exclusions'

# Maximum issues count per one linter
max-issues-per-linter: 0

# Maximum count of issues with the same text
max-same-issues: 0

# 'exclude-use-default: false' is not present in the v2 schema documentation
# and has been removed. The new default behavior does not use presets.
21 changes: 20 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,40 @@
"cSpell.enabled": true,
"cSpell.words": [
"apikey",
"bxretail",
"davinci",
"depscheck",
"devcheck",
"dupl",
"errcheck",
"exhaustruct",
"fieldalignment",
"funlen",
"github",
"goconst",
"gocyclo",
"golangci",
"GOPATH",
"gosec",
"govet",
"ineffassign",
"nlreturn",
"oauth",
"oidc",
"openapi",
"paralleltest",
"patrickcping",
"pingidentity",
"pingone",
"pkcs",
"sarif",
"testframework"
"staticcheck",
"stretchr",
"testacc",
"testframework",
"testifylint",
"unconvert",
"uuid"
],
"cSpell.ignoreWords": [
"bool",
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test-coverage:

# Run linting checks
lint:
golangci-lint run
golangci-lint run --config=.golangci.yml

# Run security scan
security:
Expand Down
5 changes: 3 additions & 2 deletions config/pingone.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import (
"net/http"
"strings"

svcOAuth2 "github.com/pingidentity/pingone-go-client/oauth2"
"github.com/pingidentity/pingone-go-client/oidc/endpoints"
"golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials"

svcOAuth2 "github.com/pingidentity/pingone-go-client/oauth2"
"github.com/pingidentity/pingone-go-client/oidc/endpoints"
)

// Configuration represents the complete configuration for the PingOne Go Client SDK.
Expand Down
13 changes: 9 additions & 4 deletions config/pingone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"net/http"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/pingidentity/pingone-go-client/config"
"github.com/pingidentity/pingone-go-client/oauth2"
"github.com/stretchr/testify/assert"
)

func TestNewConfiguration(t *testing.T) {
Expand Down Expand Up @@ -201,7 +203,8 @@ func TestAuthEndpoints(t *testing.T) {
},
expectError: false,
validateURLs: func(t *testing.T, endpoints interface{}) {
e := endpoints.(struct{ TokenURL string })
e, ok := endpoints.(struct{ TokenURL string })
require.True(t, ok, "endpoints should be of expected type")
assert.Contains(t, e.TokenURL, "https://custom.pingone.com")
},
},
Expand All @@ -212,7 +215,8 @@ func TestAuthEndpoints(t *testing.T) {
},
expectError: false,
validateURLs: func(t *testing.T, endpoints interface{}) {
e := endpoints.(struct{ TokenURL string })
e, ok := endpoints.(struct{ TokenURL string })
require.True(t, ok, "endpoints should be of expected type")
assert.Contains(t, e.TokenURL, "https://auth.pingone.com/env-id")
},
},
Expand All @@ -223,7 +227,8 @@ func TestAuthEndpoints(t *testing.T) {
},
expectError: false,
validateURLs: func(t *testing.T, endpoints interface{}) {
e := endpoints.(struct{ TokenURL string })
e, ok := endpoints.(struct{ TokenURL string })
require.True(t, ok, "endpoints should be of expected type")
assert.Contains(t, e.TokenURL, "https://auth.pingone.com/env-id")
},
},
Expand Down
3 changes: 2 additions & 1 deletion oauth2/endpoints/endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ package endpoints_test
import (
"testing"

"github.com/pingidentity/pingone-go-client/oauth2/endpoints"
"github.com/stretchr/testify/assert"

"github.com/pingidentity/pingone-go-client/oauth2/endpoints"
)

func TestPingOneEndpoint(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion oauth2/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ package oauth2_test
import (
"testing"

"github.com/pingidentity/pingone-go-client/oauth2"
"github.com/stretchr/testify/assert"

"github.com/pingidentity/pingone-go-client/oauth2"
)

func TestGrantTypeConstants(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion oidc/endpoints/endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ package endpoints_test
import (
"testing"

"github.com/pingidentity/pingone-go-client/oidc/endpoints"
"github.com/stretchr/testify/assert"

"github.com/pingidentity/pingone-go-client/oidc/endpoints"
)

func TestPingOneOIDCEndpoint(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions pingone/test/api_da_vinci_variables_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions pingone/test/api_environments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (s *EnvironmentsApiServiceTestSuite) TestEnvironmentNeverFound() {

environmentID := uuid.New()

resp, httpRes, err := s.ApiClient.EnvironmentsApi.GetEnvironmentById(s.T().Context(), environmentID).Execute()
resp, httpRes, err := s.APIClient.EnvironmentsApi.GetEnvironmentById(s.T().Context(), environmentID).Execute()
testframework.CheckNotFound(s.T(), resp, httpRes, err)
testframework.CheckPingOneAPIErrorResponse(s.T(), err, pingone.NotFoundError{}, regexp.MustCompile("Unable to find environment"))
}
Expand All @@ -223,7 +223,7 @@ func (s *EnvironmentsApiServiceTestSuite) TestEnvironmentFullLifecycle() {
}

func (s *EnvironmentsApiServiceTestSuite) test_pingone_EnvironmentsApiService_Create(t *testing.T, payload pingone.EnvironmentCreateRequest) (environmentID uuid.UUID) {
resp, httpRes, err := s.ApiClient.EnvironmentsApi.CreateEnvironment(s.T().Context()).EnvironmentCreateRequest(payload).Execute()
resp, httpRes, err := s.APIClient.EnvironmentsApi.CreateEnvironment(s.T().Context()).EnvironmentCreateRequest(payload).Execute()
testframework.CheckCreated(t, resp, &pingone.EnvironmentResponse{}, httpRes, err)

require.NotNil(t, resp.Id)
Expand All @@ -238,7 +238,7 @@ func (s *EnvironmentsApiServiceTestSuite) test_pingone_EnvironmentsApiService_Cr
}

func (s *EnvironmentsApiServiceTestSuite) test_pingone_EnvironmentsApiService_Get(t *testing.T, environmentID uuid.UUID, payload any) {
resp, httpRes, err := s.ApiClient.EnvironmentsApi.GetEnvironmentById(s.T().Context(), environmentID).Execute()
resp, httpRes, err := s.APIClient.EnvironmentsApi.GetEnvironmentById(s.T().Context(), environmentID).Execute()
testframework.CheckFound(t, resp, &pingone.EnvironmentResponse{}, httpRes, err)

require.NotNil(t, resp.Id)
Expand All @@ -260,7 +260,7 @@ func (s *EnvironmentsApiServiceTestSuite) test_pingone_EnvironmentsApiService_Ge
}

func (s *EnvironmentsApiServiceTestSuite) test_pingone_EnvironmentsApiService_Replace(t *testing.T, environmentID uuid.UUID, payload pingone.EnvironmentReplaceRequest) {
resp, httpRes, err := s.ApiClient.EnvironmentsApi.ReplaceEnvironmentById(s.T().Context(), environmentID).EnvironmentReplaceRequest(payload).Execute()
resp, httpRes, err := s.APIClient.EnvironmentsApi.ReplaceEnvironmentById(s.T().Context(), environmentID).EnvironmentReplaceRequest(payload).Execute()
testframework.CheckReplaced(t, resp, &pingone.EnvironmentResponse{}, httpRes, err)

require.Equal(t, resp.Id, environmentID)
Expand All @@ -273,10 +273,10 @@ func (s *EnvironmentsApiServiceTestSuite) test_pingone_EnvironmentsApiService_Re
}

func (s *EnvironmentsApiServiceTestSuite) test_pingone_EnvironmentsApiService_Delete(t *testing.T, environmentID uuid.UUID) {
httpRes, err := s.ApiClient.EnvironmentsApi.DeleteEnvironmentById(s.T().Context(), environmentID).Execute()
httpRes, err := s.APIClient.EnvironmentsApi.DeleteEnvironmentById(s.T().Context(), environmentID).Execute()
testframework.CheckDeleted(t, httpRes, err)

resp, httpRes, err := s.ApiClient.EnvironmentsApi.GetEnvironmentById(s.T().Context(), environmentID).Execute()
resp, httpRes, err := s.APIClient.EnvironmentsApi.GetEnvironmentById(s.T().Context(), environmentID).Execute()
testframework.CheckNotFound(t, resp, httpRes, err)
}

Expand Down Expand Up @@ -360,7 +360,7 @@ func (s *EnvironmentsApiServiceModifyTestSuite) TestEnvironmentBillOfMaterialsFu
}

func (s *EnvironmentsApiServiceModifyTestSuite) test_pingone_EnvironmentBillOfMaterialsApiService_Get(t *testing.T, environmentID uuid.UUID, payload any) {
resp, httpRes, err := s.ApiClient.EnvironmentsApi.GetBillOfMaterialsByEnvironmentId(s.T().Context(), environmentID).Execute()
resp, httpRes, err := s.APIClient.EnvironmentsApi.GetBillOfMaterialsByEnvironmentId(s.T().Context(), environmentID).Execute()
testframework.CheckFound(t, resp, &pingone.EnvironmentBillOfMaterials{}, httpRes, err)

assert.NotNil(t, resp.Links)
Expand All @@ -383,7 +383,7 @@ func (s *EnvironmentsApiServiceModifyTestSuite) test_pingone_EnvironmentBillOfMa
}

func (s *EnvironmentsApiServiceModifyTestSuite) test_pingone_EnvironmentBillOfMaterialsApiService_Replace(t *testing.T, environmentID uuid.UUID, payload pingone.EnvironmentBillOfMaterialsReplaceRequest) {
resp, httpRes, err := s.ApiClient.EnvironmentsApi.ReplaceBillOfMaterialsByEnvironmentId(s.T().Context(), environmentID).EnvironmentBillOfMaterialsReplaceRequest(payload).Execute()
resp, httpRes, err := s.APIClient.EnvironmentsApi.ReplaceBillOfMaterialsByEnvironmentId(s.T().Context(), environmentID).EnvironmentBillOfMaterialsReplaceRequest(payload).Execute()
testframework.CheckReplaced(t, resp, &pingone.EnvironmentBillOfMaterials{}, httpRes, err)

assert.NotNil(t, resp.Links)
Expand Down
4 changes: 3 additions & 1 deletion testframework/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ func checkAPIFailure(t *testing.T, responseDataObj any, httpResponse *http.Respo
assert.Equal(t, expectedStatusCode, httpResponse.StatusCode)
}

func CheckPingOneAPIErrorResponse(t *testing.T, httpError error, expectedErrorType any, expectedErrorMessageRegex *regexp.Regexp) {
// CheckPingOneAPIErrorResponse verifies that the error is of the expected type.
// The expectedErrorMessageRegex parameter is currently unused but reserved for future validation.
func CheckPingOneAPIErrorResponse(t *testing.T, httpError error, expectedErrorType any, _ *regexp.Regexp) {
require.IsType(t, expectedErrorType, httpError)

// assert.NotEmpty(t, errorModel.Id)
Expand Down
Loading