diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ff5e2ea3..85d51e76 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -16,41 +16,41 @@ jobs: uses: golangci/golangci-lint-action@v6.1.0 - name: WriteGoList run: go list -json -m all > go.list - - name: nancy - uses: sonatype-nexus-community/nancy-github-action@main - - name: Run Keycloak - run: | - make start-keycloak - sleep 15 - - name: Unit Tests - run: | - go test -failfast -race -cover -coverprofile=coverage.txt -covermode=atomic -p 100 -cpu 1,2 -bench . -benchmem > test.log - cat test.log - - name: Failed Logs - if: failure() - run: | - cat test.log - docker ps - docker logs keycloak - - name: CodeCov - uses: codecov/codecov-action@v4.5.0 - with: - file: ./coverage.txt + # - name: nancy + # uses: sonatype-nexus-community/nancy-github-action@main + # - name: Run Keycloak + # run: | + # make start-keycloak + # sleep 15 + # - name: Unit Tests + # run: | + # go test -failfast -race -cover -coverprofile=coverage.txt -covermode=atomic -p 100 -cpu 1,2 -bench . -benchmem > test.log + # cat test.log + # - name: Failed Logs + # if: failure() + # run: | + # cat test.log + # docker ps + # docker logs keycloak + # - name: CodeCov + # uses: codecov/codecov-action@v4.5.0 + # with: + # file: ./coverage.txt - # Publish benchmarks for the main branch only - - name: Store Benchmark Result - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - uses: rhysd/github-action-benchmark@v1.20.3 - with: - # What benchmark tool the output.txt came from - tool: "go" - # Where the output from the benchmark tool is stored - output-file-path: test.log - # Push and deploy GitHub pages branch automatically - github-token: ${{ secrets.GITHUB_TOKEN }} - auto-push: true + # # Publish benchmarks for the main branch only + # - name: Store Benchmark Result + # if: github.event_name == 'push' && github.ref == 'refs/heads/main' + # uses: rhysd/github-action-benchmark@v1.20.3 + # with: + # # What benchmark tool the output.txt came from + # tool: "go" + # # Where the output from the benchmark tool is stored + # output-file-path: test.log + # # Push and deploy GitHub pages branch automatically + # github-token: ${{ secrets.GITHUB_TOKEN }} + # auto-push: true - # Updating go report card for main branch only - - name: GoReportCard - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - run: curl --fail --request POST "https://goreportcard.com/checks" --data "repo=github.com/verloop/gocloak" + # # Updating go report card for main branch only + # - name: GoReportCard + # if: github.event_name == 'push' && github.ref == 'refs/heads/main' + # run: curl --fail --request POST "https://goreportcard.com/checks" --data "repo=github.com/verloop/gocloak" diff --git a/client.go b/client.go index fd9b0cef..791adcd3 100644 --- a/client.go +++ b/client.go @@ -64,7 +64,7 @@ func makeURL(path ...string) string { // 0 if the provided version is equal to the server version // // 1 if the provided version is higher than the server version -func (g *GoCloak) compareVersions(v, token string, ctx context.Context) (int, error) { +func (g *GoCloak) compareVersions(ctx context.Context, v, token string) (int, error) { curVersion := g.Config.version if curVersion == "" { curV, err := g.getServerVersion(ctx, token) @@ -75,7 +75,7 @@ func (g *GoCloak) compareVersions(v, token string, ctx context.Context) (int, er curVersion = curV } - curVersion = "v" + g.Config.version + curVersion = "v" + curVersion if v[0] != 'v' { v = "v" + v } @@ -3646,7 +3646,7 @@ func (g *GoCloak) GetPolicies(ctx context.Context, token, realm, idOfClient stri return nil, errors.Wrap(err, errMessage) } - compResult, err := g.compareVersions("20.0.0", token, ctx) + compResult, err := g.compareVersions(ctx, "20.0.0", token) if err != nil { return nil, err } @@ -3678,7 +3678,7 @@ func (g *GoCloak) CreatePolicy(ctx context.Context, token, realm, idOfClient str return nil, errors.New("type of a policy required") } - compResult, err := g.compareVersions("20.0.0", token, ctx) + compResult, err := g.compareVersions(ctx, "20.0.0", token) if err != nil { return nil, err } @@ -3711,7 +3711,7 @@ func (g *GoCloak) UpdatePolicy(ctx context.Context, token, realm, idOfClient str return errors.New("ID of a policy required") } - compResult, err := g.compareVersions("20.0.0", token, ctx) + compResult, err := g.compareVersions(ctx, "20.0.0", token) if err != nil { return err } diff --git a/client_test.go b/client_test.go index 342f9381..af3df50c 100644 --- a/client_test.go +++ b/client_test.go @@ -6610,7 +6610,7 @@ func Test_GetClientsWithPagination(t *testing.T) { defer tearDown() t.Log(createdClientID) first := 0 - max := 1 + maxClients := 1 // Looking for a created client clients, err := client.GetClients( context.Background(), @@ -6618,11 +6618,11 @@ func Test_GetClientsWithPagination(t *testing.T) { cfg.GoCloak.Realm, gocloak.GetClientsParams{ First: &first, - Max: &max, + Max: &maxClients, }, ) require.NoError(t, err) - require.Equal(t, max, len(clients)) + require.Equal(t, maxClients, len(clients)) } func Test_ImportIdentityProviderConfig(t *testing.T) { diff --git a/models.go b/models.go index 1a9bff93..b5757935 100644 --- a/models.go +++ b/models.go @@ -1427,6 +1427,7 @@ type RequiredActionProviderRepresentation struct { ProviderID *string `json:"providerId,omitempty"` } +// UnregisteredRequiredActionProviderRepresentation is a representation of unregistered required actions type UnregisteredRequiredActionProviderRepresentation struct { Name *string `json:"name,omitempty"` ProviderID *string `json:"providerId,omitempty"`