Skip to content
Open
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
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -272,42 +272,42 @@ ci-test: ci-test-go
test-ginkgo: ginkgo
@echo "ginkgo $(GINKGO_FLAGS) $(TEST)"
@cd $(ROOT_DIRECTORY) && \
. ./env.test.sh && GOWORK=off $(TIMING_CMD) ginkgo $(GINKGO_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
. ./env.test.sh && GOWORK=off $(TIMING_CMD) ginkgo $(GINKGO_FLAGS) $(TEST)

test-ginkgo-repeat: ginkgo
@echo "ginkgo $(GINKGO_FLAGS) --repeat $(TEST_REPEAT) $(TEST)"
@cd $(ROOT_DIRECTORY) && \
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) --repeat $(TEST_REPEAT) $${GOWORK_FLAGS:-} $(TEST)
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) --repeat $(TEST_REPEAT) $(TEST)

test-ginkgo-until-failure: ginkgo
@echo "ginkgo $(GINKGO_FLAGS) --until-it-fails $(TEST)"
@cd $(ROOT_DIRECTORY) && \
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) --until-it-fails $${GOWORK_FLAGS:-} $(TEST)
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) --until-it-fails $(TEST)

test-ginkgo-watch: ginkgo
@echo "ginkgo watch $(GINKGO_FLAGS) $(TEST)"
@cd $(ROOT_DIRECTORY) && \
. ./env.test.sh && GOWORK=off ginkgo watch $(GINKGO_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
. ./env.test.sh && GOWORK=off ginkgo watch $(GINKGO_FLAGS) $(TEST)

ci-test-ginkgo: ginkgo
@echo "ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) $(TEST)"
@cd $(ROOT_DIRECTORY) && \
. ./env.test.sh && GOWORK=off $(TIMING_CMD) ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
. ./env.test.sh && GOWORK=off $(TIMING_CMD) ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) $(TEST)

ci-test-ginkgo-repeat: ginkgo
@echo "ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) --repeat $(TEST_REPEAT) $(TEST)"
@cd $(ROOT_DIRECTORY) && \
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) --repeat $(TEST_REPEAT) $${GOWORK_FLAGS:-} $(TEST)
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) --repeat $(TEST_REPEAT) $(TEST)

ci-test-ginkgo-until-failure: ginkgo
@echo "ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) --until-it-fails $(TEST)"
@cd $(ROOT_DIRECTORY) && \
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) --until-it-fails $${GOWORK_FLAGS:-} $(TEST)
. ./env.test.sh && GOWORK=off ginkgo $(GINKGO_FLAGS) $(GINKGO_CI_FLAGS) --until-it-fails $(TEST)

ci-test-ginkgo-watch: ginkgo
@echo "ginkgo watch $(GINKGO_FLAGS) $(GINKGO_CI_WATCH_FLAGS) $(TEST)"
@cd $(ROOT_DIRECTORY) && \
. ./env.test.sh && GOWORK=off ginkgo watch $(GINKGO_FLAGS) $(GINKGO_CI_WATCH_FLAGS) $${GOWORK_FLAGS:-} $(TEST)
. ./env.test.sh && GOWORK=off ginkgo watch $(GINKGO_FLAGS) $(GINKGO_CI_WATCH_FLAGS) $(TEST)

test-go:
@echo "go test $(GOTEST_FLAGS) $(GOTEST_PKGS)"
Expand Down
3 changes: 2 additions & 1 deletion appvalidate/coastal_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/kelseyhightower/envconfig"

"github.com/tidepool-org/platform/log"
"github.com/tidepool-org/platform/request"
"github.com/tidepool-org/platform/structure"
structValidator "github.com/tidepool-org/platform/structure/validator"
)
Expand Down Expand Up @@ -171,7 +172,7 @@ func (c *CoastalSecrets) GetSecret(ctx context.Context, partnerDataRaw []byte) (
if err != nil {
return nil, fmt.Errorf("unable to issue Coastal API request: %w", err)
}
defer res.Body.Close()
defer request.DrainAndClose(res.Body)

if res.StatusCode < 200 || res.StatusCode >= 300 {
var msg string
Expand Down
3 changes: 2 additions & 1 deletion appvalidate/palm_tree_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/kelseyhightower/envconfig"

"github.com/tidepool-org/platform/log"
"github.com/tidepool-org/platform/request"
"github.com/tidepool-org/platform/structure"
structValidator "github.com/tidepool-org/platform/structure/validator"
)
Expand Down Expand Up @@ -147,7 +148,7 @@ func (pt *PalmTreeSecrets) GetSecret(ctx context.Context, partnerDataRaw []byte)
if err != nil {
return nil, fmt.Errorf("unable to issue PalmTree API request: %w", err)
}
defer res.Body.Close()
defer request.DrainAndClose(res.Body)

if res.StatusCode < 200 || res.StatusCode >= 300 {
var body map[string]any
Expand Down
29 changes: 27 additions & 2 deletions auth/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ func NewClient(cfg *Config, authorizeAs platform.AuthorizeAs, name string, lgr l
return nil, err
}

extrnl, err := NewExternal(cfg.ExternalConfig, authorizeAs, name, lgr)
external, err := NewExternal(cfg.ExternalConfig, authorizeAs, name, lgr)
if err != nil {
return nil, err
}

return &Client{
client: clnt,
External: extrnl,
External: external,
}, nil
}

Expand Down Expand Up @@ -186,6 +186,31 @@ func (c *Client) DeleteProviderSession(ctx context.Context, id string) error {
return c.client.RequestData(ctx, http.MethodDelete, url, nil, nil, nil)
}

func (c *Client) RefreshProviderSession(ctx context.Context, id string, refresh *auth.ProviderSessionRefresh) (*auth.ProviderSession, error) {
if ctx == nil {
return nil, errors.New("context is missing")
}
if id == "" {
return nil, errors.New("id is missing")
}
if refresh == nil {
refresh = &auth.ProviderSessionRefresh{}
} else if err := structureValidator.New(log.LoggerFromContext(ctx)).Validate(refresh); err != nil {
return nil, errors.Wrap(err, "refresh is invalid")
}

url := c.client.ConstructURL("v1", "provider_sessions", id, "refresh")
providerSession := &auth.ProviderSession{}
if err := c.client.RequestData(ctx, http.MethodPost, url, nil, refresh, providerSession); err != nil {
if request.IsErrorResourceNotFound(err) {
return nil, nil
}
return nil, err
}

return providerSession, nil
}

func (c *Client) ListUserRestrictedTokens(ctx context.Context, userID string, filter *auth.RestrictedTokenFilter, pagination *page.Pagination) (auth.RestrictedTokens, error) {
if ctx == nil {
return nil, errors.New("context is missing")
Expand Down
Loading