Skip to content

Commit

Permalink
release: v0.0.3
Browse files Browse the repository at this point in the history
- Fix incorrectly applying client_credentials validation to api_token
  cred method [openfga/sdk-generator#21](openfga/sdk-generator#21)
- Target go 1.19
- Bump golang.org/x/net
- Use [govulncheck](https://go.dev/blog/vuln) in CI to check for issues
  • Loading branch information
rhamzeh committed Sep 7, 2022
1 parent 4306661 commit ee8869f
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 9 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
cache: true
- name: Build
run: go build -v ./...
Expand All @@ -39,7 +39,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
cache: true
- name: Build
run: go build -v ./...
Expand All @@ -59,14 +59,20 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest

- name: Run govulncheck
run: govulncheck ./...

create-release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## v0.0.3

### [0.0.3](https://github.com/openfga/go-sdk/compare/v0.0.2...v0.0.3) (2022-09-07)

- Fix incorrectly applying client_credentials validation to api_token cred method [openfga/sdk-generator#21](https://github.com/openfga/sdk-generator/pull/21)
- Target go 1.19
- Bump golang.org/x/net
- Use [govulncheck](https://go.dev/blog/vuln) in CI to check for issues

## v0.0.2

### [0.0.2](https://github.com/openfga/go-sdk/compare/v0.0.1...v0.0.2) (2022-08-15)
Expand Down
2 changes: 1 addition & 1 deletion configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/openfga/go-sdk/credentials"
)

var SdkVersion = "0.0.2"
var SdkVersion = "0.0.3"

// RetryParams configures configuration for retry in case of HTTP too many request
type RetryParams struct {
Expand Down
2 changes: 1 addition & 1 deletion credentials/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (c *Credentials) ValidateCredentialsConfig() error {
conf := c.Config
if c.Method == CredentialsMethodApiToken && (conf == nil || conf.ApiToken == "") {
return fmt.Errorf("CredentialsConfig.ApiToken is required when CredentialsMethod is CredentialsMethodApiToken (%s)", c.Method)
} else if c.Method == CredentialsMethodApiToken {
} else if c.Method == CredentialsMethodClientCredentials {
if conf == nil ||
conf.ClientCredentialsClientId == "" ||
conf.ClientCredentialsClientSecret == "" ||
Expand Down
43 changes: 43 additions & 0 deletions fga_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,49 @@ func TestOpenFgaApiConfiguration(t *testing.T) {
}
})

t.Run("should issue a successful network call when using ApiToken credential method", func(t *testing.T) {
configuration, err := NewConfiguration(Configuration{
ApiHost: "api.fga.example",
StoreId: "6c181474-aaa1-4df7-8929-6e7b3a992754",
Credentials: &credentials.Credentials{
Method: credentials.CredentialsMethodApiToken,
Config: &credentials.Config{
ApiToken: "some-token",
},
},
})
if err != nil {
t.Fatalf("%v", err)
}

apiClient := NewAPIClient(configuration)

httpmock.Activate()
defer httpmock.DeactivateAndReset()
httpmock.RegisterResponder("GET", fmt.Sprintf("%s://%s/stores/%s/authorization-models", configuration.ApiScheme, configuration.ApiHost, configuration.StoreId),
func(req *http.Request) (*http.Response, error) {
resp, err := httpmock.NewJsonResponse(200, ReadAuthorizationModelsResponse{AuthorizationModels: &[]AuthorizationModel{
{
Id: PtrString("1uHxCSuTP0VKPYSnkq1pbb1jeZw"),
TypeDefinitions: &[]TypeDefinition{},
},
{
Id: PtrString("GtQpMohWezFmIbyXxVEocOCxxgq"),
TypeDefinitions: &[]TypeDefinition{},
},
}})
if err != nil {
return httpmock.NewStringResponse(500, ""), nil
}
return resp, nil
},
)

if _, _, err = apiClient.OpenFgaApi.ReadAuthorizationModels(context.Background()).Execute(); err != nil {
t.Fatalf("%v", err)
}
})

t.Run("In ClientCredentials method, providing no client id, secret, audience or issuer should error", func(t *testing.T) {
_, err := NewConfiguration(Configuration{
ApiHost: "https://api.fga.example",
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/openfga/go-sdk

go 1.18
go 1.19

require (
github.com/jarcoal/httpmock v1.2.0
golang.org/x/net v0.0.0-20220812174116-3211cb980234
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc=
github.com/jarcoal/httpmock v1.2.0/go.mod h1:oCoTsnAz4+UoOUIf5lJOWV2QQIW5UoeUI6aM2YnWAZk=
github.com/maxatome/go-testdeep v1.11.0 h1:Tgh5efyCYyJFGUYiT0qxBSIDeXw0F5zSoatlou685kk=
golang.org/x/net v0.0.0-20220812174116-3211cb980234 h1:RDqmgfe7SvlMWoqC3xwQ2blLO3fcWcxMa3eBLRdRW7E=
golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 h1:1WGATo9HAhkWMbfyuVU0tEFP88OIkUvwaHFveQPvzCQ=
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=

0 comments on commit ee8869f

Please sign in to comment.