Skip to content

Commit 996e427

Browse files
committed
Fix windows tests
Signed-off-by: Guilherme Carvalho <[email protected]>
1 parent 8cacc0a commit 996e427

File tree

2 files changed

+42
-19
lines changed

2 files changed

+42
-19
lines changed

support/oidc-discovery-provider/cert_manager_test.go

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func TestTLSConfig(t *testing.T) {
156156
})
157157
writeFile(t, certFilePath, oidcServerCertUpdatedPem)
158158

159-
clk.Add(10 * time.Millisecond)
159+
clk.Add(20 * time.Millisecond)
160160

161161
require.Eventuallyf(t, func() bool {
162162
cert, err := tlsConfig.GetCertificate(chInfo)
@@ -265,12 +265,19 @@ func TestTLSConfig(t *testing.T) {
265265
writeFile(t, certFilePath, oidcServerCertPem)
266266

267267
clk.Add(10 * time.Millisecond)
268-
cert, err := tlsConfig.GetCertificate(chInfo)
269-
require.NoError(t, err)
270-
require.Len(t, cert.Certificate, 1)
271-
x509Cert, err := x509.ParseCertificate(cert.Certificate[0])
272-
require.NoError(t, err)
273-
require.Equal(t, oidcServerCert, x509Cert)
268+
269+
require.Eventuallyf(t, func() bool {
270+
cert, err := tlsConfig.GetCertificate(chInfo)
271+
if err != nil {
272+
return false
273+
}
274+
require.Len(t, cert.Certificate, 1)
275+
x509Cert, err := x509.ParseCertificate(cert.Certificate[0])
276+
if err != nil {
277+
return false
278+
}
279+
return reflect.DeepEqual(oidcServerCert, x509Cert)
280+
}, 10*time.Second, 10*time.Millisecond, "Failed to assert updated certificate")
274281
})
275282

276283
t.Run("delete cert files start error log loop", func(t *testing.T) {
@@ -282,12 +289,14 @@ func TestTLSConfig(t *testing.T) {
282289

283290
// Assert error logs that will keep triggering until the key is created again.
284291
errLogs := map[time.Time]struct{}{}
285-
for _, entry := range logHook.AllEntries() {
286-
if entry.Level == logrus.ErrorLevel && strings.Contains(entry.Message, fmt.Sprintf("Failed to get file info, file path %q does not exist anymore; please check if the path is correct", keyFilePath)) {
287-
errLogs[entry.Time] = struct{}{}
292+
require.Eventuallyf(t, func() bool {
293+
for _, entry := range logHook.AllEntries() {
294+
if entry.Level == logrus.ErrorLevel && strings.Contains(entry.Message, fmt.Sprintf("Failed to get file info, file path %q does not exist anymore; please check if the path is correct", keyFilePath)) {
295+
errLogs[entry.Time] = struct{}{}
296+
}
288297
}
289-
}
290-
require.Len(t, errLogs, 5)
298+
return len(errLogs) == 5
299+
}, 10*time.Second, 10*time.Millisecond, "Failed to assert error logs")
291300

292301
removeFile(t, certFilePath)
293302

support/oidc-discovery-provider/config_windows_test.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ func parseConfigCasesOS() []parseConfigCase {
134134
key_file_path = "test"
135135
}
136136
server_api {
137-
address = "unix:///some/socket/path"
137+
experimental {
138+
named_pipe_name = "\\name\\for\\server\\api"
139+
}
138140
}
139141
`,
140142
out: &Config{
@@ -151,7 +153,9 @@ func parseConfigCasesOS() []parseConfigCase {
151153
RawAddr: ":433",
152154
},
153155
ServerAPI: &ServerAPIConfig{
154-
Address: "unix:///some/socket/path",
156+
Experimental: experimentalServerAPIConfig{
157+
NamedPipeName: "\\name\\for\\server\\api",
158+
},
155159
PollInterval: defaultPollInterval,
156160
},
157161
},
@@ -167,7 +171,9 @@ func parseConfigCasesOS() []parseConfigCase {
167171
addr = "127.0.0.1:9090"
168172
}
169173
server_api {
170-
address = "unix:///some/socket/path"
174+
experimental {
175+
named_pipe_name = "\\name\\for\\server\\api"
176+
}
171177
}
172178
`,
173179
out: &Config{
@@ -185,7 +191,9 @@ func parseConfigCasesOS() []parseConfigCase {
185191
RawAddr: "127.0.0.1:9090",
186192
},
187193
ServerAPI: &ServerAPIConfig{
188-
Address: "unix:///some/socket/path",
194+
Experimental: experimentalServerAPIConfig{
195+
NamedPipeName: "\\name\\for\\server\\api",
196+
},
189197
PollInterval: defaultPollInterval,
190198
},
191199
},
@@ -198,7 +206,9 @@ func parseConfigCasesOS() []parseConfigCase {
198206
key_file_path = "test"
199207
}
200208
server_api {
201-
address = "unix:///some/socket/path"
209+
experimental {
210+
named_pipe_name = "\\name\\for\\server\\api"
211+
}
202212
}
203213
`,
204214
err: "cert_file_path must be configured in the serving_cert_file configuration section",
@@ -211,7 +221,9 @@ func parseConfigCasesOS() []parseConfigCase {
211221
cert_file_path = "test"
212222
}
213223
server_api {
214-
address = "unix:///some/socket/path"
224+
experimental {
225+
named_pipe_name = "\\name\\for\\server\\api"
226+
}
215227
}
216228
`,
217229
err: "key_file_path must be configured in the serving_cert_file configuration section",
@@ -226,7 +238,9 @@ func parseConfigCasesOS() []parseConfigCase {
226238
addr = "127.0.0.1.1:9090"
227239
}
228240
server_api {
229-
address = "unix:///some/socket/path"
241+
experimental {
242+
named_pipe_name = "\\name\\for\\server\\api"
243+
}
230244
}
231245
`,
232246
err: "invalid addr in the serving_cert_file configuration section: lookup 127.0.0.1.1: no such host",

0 commit comments

Comments
 (0)