Skip to content

Commit

Permalink
Merge pull request #185 from okta/don't_cancel_context
Browse files Browse the repository at this point in the history
Removed cancel function for context
  • Loading branch information
bogdanprodan-okta authored Nov 14, 2020
2 parents 9cb804f + 5e4721d commit 3d98f0e
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 19 deletions.
20 changes: 12 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
language: go

go:
- 1.15.x
- tip

script:
- go mod download
- make test

jobs:
include:
- stage: test_go_1.13
go: 1.13.x
script:
- go mod download
- make test
- stage: test_go_tip
go: tip
script:
- go mod download
- make test
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
Running changelog of releases since `2.0.0-rc.4`

## v2.2.1
### Bug Fixes
- Update default connection Timeout to `60` seconds (#185)
- Http Client now uses `Timeout` setting for connection timeout (#185)
- SDK no longer cancels context (#185)

## v2.2.0
### New Structs
- `OpenIdConnectApplicationSettingsClientKeys`
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pull-spec:
cp spec-raw/dist/spec.json openapi/spec.json
rm -fr spec-raw


test:
make test:all

Expand Down
4 changes: 2 additions & 2 deletions okta/okta.go

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

9 changes: 5 additions & 4 deletions okta/requestExecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ func NewRequestExecutor(httpClient *http.Client, cache cache.Cache, config *conf
tr := &http.Transport{
IdleConnTimeout: 30 * time.Second,
}
re.httpClient = &http.Client{Transport: tr}
re.httpClient = &http.Client{
Transport: tr,
Timeout: time.Second * time.Duration(re.config.Okta.Client.ConnectionTimeout),
}
}

return &re
Expand Down Expand Up @@ -283,9 +286,7 @@ func (re *RequestExecutor) doWithRetries(ctx context.Context, req *http.Request)
err error
)
if re.config.Okta.Client.RequestTimeout > 0 {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, time.Second*time.Duration(re.config.Okta.Client.RequestTimeout))
defer cancel()
ctx, _ = context.WithTimeout(ctx, time.Second*time.Duration(re.config.Okta.Client.RequestTimeout))
}
bOff := &oktaBackoff{
ctx: ctx,
Expand Down
4 changes: 2 additions & 2 deletions openapi/generator/templates/okta.go.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"gopkg.in/yaml.v3"
)

const Version = "2.2.0"
const Version = "2.2.1"

type Client struct {
config *config
Expand Down Expand Up @@ -96,7 +96,7 @@ func setConfigDefaults(c *config) {
var conf []ConfigSetter

conf = append(conf,
WithConnectionTimeout(30),
WithConnectionTimeout(60),
WithCache(true),
WithCacheTtl(300),
WithCacheTti(300),
Expand Down
46 changes: 44 additions & 2 deletions tests/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,53 @@ func sweep() error {
if err != nil {
return err
}
return sweepUsers(ctx, client)
err = sweepUsers(ctx, client)
if err != nil {
return err
}
err = sweepGroups(ctx, client)
if err != nil {
return err
}
return sweepGroupRules(ctx, client)
}

func sweepGroups(ctx context.Context, client *okta.Client) error {
groups, _, err := client.Group.ListGroups(ctx, &query.Params{Q: "Group-Member-Rule"})
if err != nil {
return err
}
for _, g := range groups {
_, err = client.Group.DeleteGroup(ctx, g.Id)
if err != nil {
return err
}
}
return nil
}

func sweepGroupRules(ctx context.Context, client *okta.Client) error {
groupRules, _, err := client.Group.ListGroupRules(ctx, &query.Params{Q: "Test"})
if err != nil {
return err
}
for _, g := range groupRules {
if g.Status == "ACTIVE" {
_, err = client.Group.DeactivateGroupRule(ctx, g.Id)
if err != nil {
return err
}
}
_, err = client.Group.DeleteGroupRule(ctx, g.Id)
if err != nil {
return err
}
}
return nil
}

func sweepUsers(ctx context.Context, client *okta.Client) error {
users, _, err := client.User.ListUsers(ctx, &query.Params{Q:"john-"})
users, _, err := client.User.ListUsers(ctx, &query.Params{Q: "john-"})
if err != nil {
return err
}
Expand Down

0 comments on commit 3d98f0e

Please sign in to comment.