Skip to content

Commit b4d8591

Browse files
gaultierory-bot
authored andcommitted
fix: remove flaky test for unused function
GitOrigin-RevId: 736a6ab0e4bbdc424705c3d4589caf61b72d00d1
1 parent 6e6cc75 commit b4d8591

5 files changed

Lines changed: 7 additions & 47 deletions

File tree

driver/config/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/pkg/errors"
2727
"github.com/rs/cors"
2828
"github.com/stretchr/testify/require"
29-
"go.opentelemetry.io/otel/trace/noop"
3029
"golang.org/x/net/publicsuffix"
3130

3231
"github.com/ory/kratos/x"
@@ -451,10 +450,6 @@ func (p *Config) validateIdentitySchemas(ctx context.Context) error {
451450
httpx.ResilientClientWithLogger(p.l),
452451
httpx.ResilientClientWithMaxRetry(2),
453452
httpx.ResilientClientWithConnectionTimeout(30 * time.Second),
454-
// Tracing still works correctly even though we pass a no-op tracer
455-
// here, because the otelhttp package will preferentially use the
456-
// tracer from the incoming request context over this one.
457-
httpx.ResilientClientWithTracer(noop.NewTracerProvider().Tracer("github.com/ory/kratos/driver/config")),
458453
}
459454

460455
if o, ok := ctx.Value(validateIdentitySchemasClientKey).([]httpx.ResilientOptions); ok {

oryx/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ format: .bin/ory node_modules
1313
npm exec -- prettier --write .
1414

1515
.bin/golangci-lint: Makefile
16-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b .bin v1.64.8
16+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b .bin v2.4.0
1717

1818
.bin/licenses: Makefile
1919
curl https://raw.githubusercontent.com/ory/ci/master/licenses/install | sh

oryx/httpx/resilient_client.go

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"net/http"
1111
"time"
1212

13-
"go.opentelemetry.io/otel/trace"
1413
"golang.org/x/oauth2"
1514

1615
"github.com/hashicorp/go-retryablehttp"
@@ -20,16 +19,12 @@ import (
2019

2120
type resilientOptions struct {
2221
c *http.Client
23-
oauthConfig *oauth2.Config
24-
oauthToken *oauth2.Token
2522
l interface{}
2623
retryWaitMin time.Duration
2724
retryWaitMax time.Duration
2825
retryMax int
2926
noInternalIPs bool
3027
internalIPExceptions []string
31-
ipV6 bool
32-
tracer trace.Tracer
3328
}
3429

3530
func newResilientOptions() *resilientOptions {
@@ -40,20 +35,12 @@ func newResilientOptions() *resilientOptions {
4035
retryWaitMax: 30 * time.Second,
4136
retryMax: 4,
4237
l: log.New(io.Discard, "", log.LstdFlags),
43-
ipV6: true,
4438
}
4539
}
4640

4741
// ResilientOptions is a set of options for the ResilientClient.
4842
type ResilientOptions func(o *resilientOptions)
4943

50-
// ResilientClientWithTracer wraps the http clients transport with a tracing instrumentation
51-
func ResilientClientWithTracer(tracer trace.Tracer) ResilientOptions {
52-
return func(o *resilientOptions) {
53-
o.tracer = tracer
54-
}
55-
}
56-
5744
// ResilientClientWithMaxRetry sets the maximum number of retries.
5845
func ResilientClientWithMaxRetry(retryMax int) ResilientOptions {
5946
return func(o *resilientOptions) {
@@ -104,12 +91,6 @@ func ResilientClientAllowInternalIPRequestsTo(urlGlobs ...string) ResilientOptio
10491
}
10592
}
10693

107-
func ResilientClientNoIPv6() ResilientOptions {
108-
return func(o *resilientOptions) {
109-
o.ipV6 = false
110-
}
111-
}
112-
11394
// NewResilientClient creates a new ResilientClient.
11495
func NewResilientClient(opts ...ResilientOptions) *retryablehttp.Client {
11596
o := newResilientOptions()
@@ -119,12 +100,12 @@ func NewResilientClient(opts ...ResilientOptions) *retryablehttp.Client {
119100

120101
if o.noInternalIPs {
121102
o.c.Transport = &noInternalIPRoundTripper{
122-
onWhitelist: ifelse(o.ipV6, allowInternalAllowIPv6, allowInternalProhibitIPv6),
123-
notOnWhitelist: ifelse(o.ipV6, prohibitInternalAllowIPv6, prohibitInternalProhibitIPv6),
103+
onWhitelist: allowInternalAllowIPv6,
104+
notOnWhitelist: prohibitInternalAllowIPv6,
124105
internalIPExceptions: o.internalIPExceptions,
125106
}
126107
} else {
127-
o.c.Transport = ifelse(o.ipV6, allowInternalAllowIPv6, allowInternalProhibitIPv6)
108+
o.c.Transport = allowInternalAllowIPv6
128109
}
129110

130111
cl := retryablehttp.NewClient()
@@ -155,10 +136,3 @@ func SetOAuth2(ctx context.Context, cl *retryablehttp.Client, c OAuth2Config, t
155136
type OAuth2Config interface {
156137
Client(context.Context, *oauth2.Token) *http.Client
157138
}
158-
159-
func ifelse[A any](b bool, x, y A) A {
160-
if b {
161-
return x
162-
}
163-
return y
164-
}

oryx/httpx/ssrf.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ func (n noInternalIPRoundTripper) RoundTrip(request *http.Request) (*http.Respon
5555
}
5656

5757
var (
58-
prohibitInternalAllowIPv6 http.RoundTripper
59-
prohibitInternalProhibitIPv6 http.RoundTripper
60-
allowInternalAllowIPv6 http.RoundTripper
61-
allowInternalProhibitIPv6 http.RoundTripper
58+
prohibitInternalAllowIPv6 http.RoundTripper
59+
allowInternalAllowIPv6 http.RoundTripper
6260
)
6361

6462
func init() {
@@ -79,7 +77,6 @@ func init() {
7977
t.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
8078
return d.DialContext(ctx, "tcp4", addr)
8179
}
82-
prohibitInternalProhibitIPv6 = OTELTraceTransport(t)
8380
}
8481

8582
func init() {
@@ -122,7 +119,6 @@ func init() {
122119
t.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
123120
return d.DialContext(ctx, "tcp4", addr)
124121
}
125-
allowInternalProhibitIPv6 = OTELTraceTransport(t)
126122
}
127123

128124
func newDefaultTransport() (*http.Transport, *net.Dialer) {

selfservice/strategy/password/validator.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"strings"
1414
"time"
1515

16-
"go.opentelemetry.io/otel/trace/noop"
17-
1816
"github.com/ory/kratos/text"
1917

2018
"github.com/arbovm/levenshtein"
@@ -85,10 +83,7 @@ func NewDefaultPasswordValidatorStrategy(reg validatorDependencies) (*DefaultPas
8583
return &DefaultPasswordValidator{
8684
Client: httpx.NewResilientClient(
8785
httpx.ResilientClientWithConnectionTimeout(time.Second),
88-
// Tracing still works correctly even though we pass a no-op tracer
89-
// here, because the otelhttp package will preferentially use the
90-
// tracer from the incoming request context over this one.
91-
httpx.ResilientClientWithTracer(noop.NewTracerProvider().Tracer("github.com/ory/kratos/selfservice/strategy/password"))),
86+
),
9287
reg: reg,
9388
hashes: cache,
9489
minIdentifierPasswordDist: 5, maxIdentifierPasswordSubstrThreshold: 0.5,

0 commit comments

Comments
 (0)