Skip to content

Commit 849ca39

Browse files
hcsa73Henrique Santos
andauthored
Remove Key Flow unused methods (#327)
* Remove functions * Add changelogs * Add details to changelog * Re-add GetToken * Fix changelog * Fix changelog --------- Co-authored-by: Henrique Santos <[email protected]>
1 parent 169796b commit 849ca39

File tree

4 files changed

+12
-39
lines changed

4 files changed

+12
-39
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
## Release (YYYY-MM-DD)
22

33
- `core`: [v0.y.z]
4-
- **Feature:** Add package `runtime`, which implements methods to be used when performing API requests
4+
- **Feature:** Add package `runtime`, which implements methods to be used when performing API requests.
55
- **Feature:** Add method `WithCaptureHTTPResponse` to package `runtime`, which does the same as `config.WithCaptureHTTPResponse`. Method was moved to avoid confusion due to it not being a configuration option, and will be removed in a later release.
66
- **Deprecation:** Mark method `config.WithCaptureHTTPResponse` as deprecated, to avoid confusion due to it not being a configuration option. Use `runtime.WithCaptureHTTPResponse` instead.
7-
- **Deprecation:** Marked method `config.WithJWKSEndpoint` as deprecated. Validation using JWKS was removed, for being redundant with token validation done in the APIs. This option has no effect
7+
- **Deprecation:** Mark method `config.WithJWKSEndpoint` as deprecated. Validation using JWKS was removed, for being redundant with token validation done in the APIs. This option has no effect.
8+
- **Breaking Change:** Remove method `KeyFlow.Clone`, that was no longer being used.
89

910
## Release (2024-02-07)
1011

core/CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
## v0.9.0 (YYYY-MM-DD)
22

3-
- **Deprecation:** Marked method `config.WithCaptureHTTPResponse` as deprecated, to avoid confusion due
4-
- **Deprecation:** Marked method `config.WithJWKSEndpoint` as deprecated. Validation using JWKS was removed, for being redundant with token validation done in the APIs. This option has no effect
3+
- **Deprecation:** Mark method `config.WithCaptureHTTPResponse` as deprecated, to avoid confusion due to it not being a configuration option. Use `runtime.WithCaptureHTTPResponse` instead.
4+
- **Deprecation:** Mark method `config.WithJWKSEndpoint` as deprecated. Validation using JWKS was removed, for being redundant with token validation done in the APIs. This option has no effect.
5+
- **Breaking Change:** Remove method `KeyFlow.Clone`, that was no longer being used.
56

67
## v0.8.0 (2024-02-16)
78

8-
- **Feature:** Add package `runtime`, which implements methods to be used when performing API requests
9+
- **Feature:** Add package `runtime`, which implements methods to be used when performing API requests.
910
- **Feature:** Add method `WithCaptureHTTPResponse` to package `runtime`, which does the same as `config.WithCaptureHTTPResponse`. Method was moved to avoid confusion due to it not being a configuration option, and will be removed in a later release.
1011

1112
## v0.7.7 (2024-02-02)

core/clients/key_flow.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,6 @@ func (c *KeyFlow) SetToken(accessToken, refreshToken string) error {
142142
return nil
143143
}
144144

145-
// Clone creates a clone of the client
146-
func (c *KeyFlow) Clone() interface{} {
147-
sc := *c
148-
nc := &sc
149-
cl := *nc.client
150-
cf := *nc.config
151-
ke := *nc.key
152-
to := *nc.token
153-
nc.client = &cl
154-
nc.config = &cf
155-
nc.key = &ke
156-
nc.token = &to
157-
return c
158-
}
159-
160145
// Roundtrip performs the request
161146
func (c *KeyFlow) RoundTrip(req *http.Request) (*http.Response, error) {
162147
if c.client == nil {

core/clients/key_flow_test.go

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99
"io"
1010
"net/http"
11-
"reflect"
1211
"strings"
1312
"testing"
1413
"time"
@@ -183,25 +182,12 @@ func TestSetToken(t *testing.T) {
183182
}
184183
}
185184

186-
func TestKeyClone(t *testing.T) {
187-
c := &KeyFlow{
188-
client: &http.Client{},
189-
config: &KeyFlowConfig{},
190-
key: &ServiceAccountKeyResponse{},
191-
token: &TokenResponseBody{},
185+
func TestKeyFlowValidateToken(t *testing.T) {
186+
// Generate a random private key
187+
privateKey := make([]byte, 32)
188+
if _, err := rand.Read(privateKey); err != nil {
189+
t.Fatal(err)
192190
}
193-
194-
clone, ok := c.Clone().(*KeyFlow)
195-
if !ok {
196-
t.Fatalf("Type assertion failed")
197-
}
198-
199-
if !reflect.DeepEqual(c, clone) {
200-
t.Errorf("Clone() = %v, want %v", clone, c)
201-
}
202-
}
203-
204-
func TestTokenExpired(t *testing.T) {
205191
tests := []struct {
206192
desc string
207193
tokenInvalid bool

0 commit comments

Comments
 (0)