Skip to content

Commit 42995bd

Browse files
authored
Remove deprecated fields (#46)
1 parent e1e5dd9 commit 42995bd

File tree

2 files changed

+0
-124
lines changed

2 files changed

+0
-124
lines changed

oauth2cli.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,6 @@ type Config struct {
9191

9292
// Logger function for debug.
9393
Logf func(format string, args ...interface{})
94-
95-
// DEPRECATED: this will be removed in the future release.
96-
// Use LocalServerBindAddress instead.
97-
// Address which the local server binds to.
98-
// Default to "127.0.0.1".
99-
LocalServerAddress string
100-
// DEPRECATED: this will be removed in the future release.
101-
// Use LocalServerBindAddress instead.
102-
// Candidates of a port which the local server binds to.
103-
// If nil or an empty slice is given, LocalServerAddress is ignored and allocate a free port.
104-
// If multiple ports are given, they are appended to LocalServerBindAddress.
105-
LocalServerPort []int
10694
}
10795

10896
func (c *Config) isLocalServerHTTPS() bool {
@@ -136,18 +124,6 @@ func (c *Config) validateAndSetDefaults() error {
136124
return nil
137125
}
138126

139-
func (c *Config) populateDeprecatedFields() {
140-
if len(c.LocalServerPort) > 0 {
141-
address := c.LocalServerAddress
142-
if address == "" {
143-
address = "127.0.0.1"
144-
}
145-
for _, port := range c.LocalServerPort {
146-
c.LocalServerBindAddress = append(c.LocalServerBindAddress, fmt.Sprintf("%s:%d", address, port))
147-
}
148-
}
149-
}
150-
151127
// GetToken performs the Authorization Code Grant Flow and returns a token received from the provider.
152128
// See https://tools.ietf.org/html/rfc6749#section-4.1
153129
//
@@ -164,7 +140,6 @@ func GetToken(ctx context.Context, c Config) (*oauth2.Token, error) {
164140
if err := c.validateAndSetDefaults(); err != nil {
165141
return nil, fmt.Errorf("invalid config: %w", err)
166142
}
167-
c.populateDeprecatedFields()
168143
code, err := receiveCodeViaLocalServer(ctx, &c)
169144
if err != nil {
170145
return nil, fmt.Errorf("authorization error: %w", err)

oauth2cli_test.go

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1 @@
11
package oauth2cli
2-
3-
import (
4-
"testing"
5-
6-
"github.com/google/go-cmp/cmp"
7-
)
8-
9-
func TestConfig_populateDeprecatedFields(t *testing.T) {
10-
t.Run("DefaultValue", func(t *testing.T) {
11-
var cfg Config
12-
cfg.populateDeprecatedFields()
13-
var want []string
14-
if diff := cmp.Diff(want, cfg.LocalServerBindAddress); diff != "" {
15-
t.Errorf("LocalServerBindAddress mismatch (-want +got):\n%s", diff)
16-
}
17-
})
18-
19-
t.Run("AddressOnly", func(t *testing.T) {
20-
cfg := Config{
21-
LocalServerAddress: "0.0.0.0",
22-
}
23-
cfg.populateDeprecatedFields()
24-
var want []string
25-
if diff := cmp.Diff(want, cfg.LocalServerBindAddress); diff != "" {
26-
t.Errorf("LocalServerBindAddress mismatch (-want +got):\n%s", diff)
27-
}
28-
})
29-
30-
t.Run("SinglePort", func(t *testing.T) {
31-
cfg := Config{
32-
LocalServerPort: []int{8000},
33-
}
34-
cfg.populateDeprecatedFields()
35-
want := []string{"127.0.0.1:8000"}
36-
if diff := cmp.Diff(want, cfg.LocalServerBindAddress); diff != "" {
37-
t.Errorf("LocalServerBindAddress mismatch (-want +got):\n%s", diff)
38-
}
39-
})
40-
41-
t.Run("SinglePortWithAddress", func(t *testing.T) {
42-
cfg := Config{
43-
LocalServerAddress: "0.0.0.0",
44-
LocalServerPort: []int{8000},
45-
}
46-
cfg.populateDeprecatedFields()
47-
want := []string{"0.0.0.0:8000"}
48-
if diff := cmp.Diff(want, cfg.LocalServerBindAddress); diff != "" {
49-
t.Errorf("LocalServerBindAddress mismatch (-want +got):\n%s", diff)
50-
}
51-
})
52-
53-
t.Run("MultiplePort", func(t *testing.T) {
54-
cfg := Config{
55-
LocalServerPort: []int{8000, 18000},
56-
}
57-
cfg.populateDeprecatedFields()
58-
want := []string{"127.0.0.1:8000", "127.0.0.1:18000"}
59-
if diff := cmp.Diff(want, cfg.LocalServerBindAddress); diff != "" {
60-
t.Errorf("LocalServerBindAddress mismatch (-want +got):\n%s", diff)
61-
}
62-
})
63-
64-
t.Run("MultiplePortWithAddress", func(t *testing.T) {
65-
cfg := Config{
66-
LocalServerAddress: "0.0.0.0",
67-
LocalServerPort: []int{8000, 18000},
68-
}
69-
cfg.populateDeprecatedFields()
70-
want := []string{"0.0.0.0:8000", "0.0.0.0:18000"}
71-
if diff := cmp.Diff(want, cfg.LocalServerBindAddress); diff != "" {
72-
t.Errorf("LocalServerBindAddress mismatch (-want +got):\n%s", diff)
73-
}
74-
})
75-
76-
t.Run("PreserveOriginalValue", func(t *testing.T) {
77-
t.Run("DefaultValue", func(t *testing.T) {
78-
cfg := Config{
79-
LocalServerBindAddress: []string{"127.0.0.1:10000"},
80-
}
81-
cfg.populateDeprecatedFields()
82-
want := []string{"127.0.0.1:10000"}
83-
if diff := cmp.Diff(want, cfg.LocalServerBindAddress); diff != "" {
84-
t.Errorf("LocalServerBindAddress mismatch (-want +got):\n%s", diff)
85-
}
86-
})
87-
88-
t.Run("SinglePort", func(t *testing.T) {
89-
cfg := Config{
90-
LocalServerBindAddress: []string{"127.0.0.1:10000"},
91-
LocalServerPort: []int{8000},
92-
}
93-
cfg.populateDeprecatedFields()
94-
want := []string{"127.0.0.1:10000", "127.0.0.1:8000"}
95-
if diff := cmp.Diff(want, cfg.LocalServerBindAddress); diff != "" {
96-
t.Errorf("LocalServerBindAddress mismatch (-want +got):\n%s", diff)
97-
}
98-
})
99-
})
100-
}

0 commit comments

Comments
 (0)