forked from hashicorp/vault-plugin-auth-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
path_config_test.go
618 lines (530 loc) · 18 KB
/
path_config_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
package kubeauth
import (
"context"
"crypto"
"io/ioutil"
"os"
"reflect"
"testing"
"time"
"github.com/hashicorp/vault/sdk/logical"
)
func setupLocalFiles(t *testing.T, b logical.Backend) func() {
cert, err := ioutil.TempFile("", "ca.crt")
if err != nil {
t.Fatal(err)
}
cert.WriteString(testLocalCACert)
cert.Close()
token, err := ioutil.TempFile("", "token")
if err != nil {
t.Fatal(err)
}
token.WriteString(testLocalJWT)
token.Close()
b.(*kubeAuthBackend).localCACertReader = newCachingFileReader(cert.Name(), caReloadPeriod, time.Now)
b.(*kubeAuthBackend).localSATokenReader = newCachingFileReader(token.Name(), jwtReloadPeriod, time.Now)
return func() {
os.Remove(cert.Name())
os.Remove(token.Name())
}
}
func TestConfig_Read(t *testing.T) {
b, storage := getBackend(t)
cleanup := setupLocalFiles(t, b)
defer cleanup()
data := map[string]interface{}{
"pem_keys": []string{testRSACert, testECCert},
"kubernetes_host": "host",
"kubernetes_ca_cert": testCACert,
"issuer": "",
"disable_iss_validation": false,
"disable_local_ca_jwt": false,
}
req := &logical.Request{
Operation: logical.CreateOperation,
Path: configPath,
Storage: storage,
Data: data,
}
resp, err := b.HandleRequest(context.Background(), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
req = &logical.Request{
Operation: logical.ReadOperation,
Path: configPath,
Storage: storage,
Data: nil,
}
resp, err = b.HandleRequest(context.Background(), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
if !reflect.DeepEqual(resp.Data, data) {
t.Fatalf("Expected did not equal actual: expected %#v\n got %#v\n", data, resp.Data)
}
}
func TestConfig(t *testing.T) {
b, storage := getBackend(t)
cleanup := setupLocalFiles(t, b)
defer cleanup()
// test no certificate
data := map[string]interface{}{
"kubernetes_host": "host",
}
req := &logical.Request{
Operation: logical.CreateOperation,
Path: configPath,
Storage: storage,
Data: data,
}
resp, err := b.HandleRequest(context.Background(), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
// test no host
data = map[string]interface{}{
"pem_keys": testRSACert,
}
req = &logical.Request{
Operation: logical.CreateOperation,
Path: configPath,
Storage: storage,
Data: data,
}
resp, err = b.HandleRequest(context.Background(), req)
if resp == nil || !resp.IsError() {
t.Fatal("expected error")
}
if resp.Error().Error() != "no host provided" {
t.Fatalf("got unexpected error: %v", resp.Error())
}
// test invalid cert
data = map[string]interface{}{
"pem_keys": "bad",
"kubernetes_host": "host",
}
req = &logical.Request{
Operation: logical.CreateOperation,
Path: configPath,
Storage: storage,
Data: data,
}
resp, err = b.HandleRequest(context.Background(), req)
if resp == nil || !resp.IsError() {
t.Fatal("expected error")
}
if resp.Error().Error() != "data does not contain any valid RSA or ECDSA public keys" {
t.Fatalf("got unexpected error: %v", resp.Error())
}
// Test success with no certs
data = map[string]interface{}{
"kubernetes_host": "host",
"kubernetes_ca_cert": testCACert,
}
req = &logical.Request{
Operation: logical.CreateOperation,
Path: configPath,
Storage: storage,
Data: data,
}
resp, err = b.HandleRequest(context.Background(), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
expected := &kubeConfig{
PublicKeys: []crypto.PublicKey{},
PEMKeys: []string{},
Host: "host",
CACert: testCACert,
DisableISSValidation: true,
}
conf, err := b.(*kubeAuthBackend).config(context.Background(), storage)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(expected, conf) {
t.Fatalf("expected did not match actual: expected %#v\n got %#v\n", expected, conf)
}
// Test success TokenReviewer
data = map[string]interface{}{
"kubernetes_host": "host",
"kubernetes_ca_cert": testCACert,
"token_reviewer_jwt": jwtGoodDataToken,
}
req = &logical.Request{
Operation: logical.CreateOperation,
Path: configPath,
Storage: storage,
Data: data,
}
resp, err = b.HandleRequest(context.Background(), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
cert, err := parsePublicKeyPEM([]byte(testRSACert))
if err != nil {
t.Fatal(err)
}
expected = &kubeConfig{
PublicKeys: []crypto.PublicKey{},
PEMKeys: []string{},
Host: "host",
CACert: testCACert,
TokenReviewerJWT: jwtGoodDataToken,
DisableISSValidation: true,
DisableLocalCAJwt: false,
}
conf, err = b.(*kubeAuthBackend).config(context.Background(), storage)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(expected, conf) {
t.Fatalf("expected did not match actual: expected %#v\n got %#v\n", expected, conf)
}
// Test success with one cert
data = map[string]interface{}{
"pem_keys": testRSACert,
"kubernetes_host": "host",
"kubernetes_ca_cert": testCACert,
}
req = &logical.Request{
Operation: logical.CreateOperation,
Path: configPath,
Storage: storage,
Data: data,
}
resp, err = b.HandleRequest(context.Background(), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
cert, err = parsePublicKeyPEM([]byte(testRSACert))
if err != nil {
t.Fatal(err)
}
expected = &kubeConfig{
PublicKeys: []crypto.PublicKey{cert},
PEMKeys: []string{testRSACert},
Host: "host",
CACert: testCACert,
DisableISSValidation: true,
DisableLocalCAJwt: false,
}
conf, err = b.(*kubeAuthBackend).config(context.Background(), storage)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(expected, conf) {
t.Fatalf("expected did not match actual: expected %#v\n got %#v\n", expected, conf)
}
// Test success with two certs
data = map[string]interface{}{
"pem_keys": []string{testRSACert, testECCert},
"kubernetes_host": "host",
"kubernetes_ca_cert": testCACert,
}
req = &logical.Request{
Operation: logical.CreateOperation,
Path: configPath,
Storage: storage,
Data: data,
}
resp, err = b.HandleRequest(context.Background(), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
cert, err = parsePublicKeyPEM([]byte(testRSACert))
if err != nil {
t.Fatal(err)
}
cert2, err := parsePublicKeyPEM([]byte(testECCert))
if err != nil {
t.Fatal(err)
}
expected = &kubeConfig{
PublicKeys: []crypto.PublicKey{cert, cert2},
PEMKeys: []string{testRSACert, testECCert},
Host: "host",
CACert: testCACert,
DisableISSValidation: true,
DisableLocalCAJwt: false,
}
conf, err = b.(*kubeAuthBackend).config(context.Background(), storage)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(expected, conf) {
t.Fatalf("expected did not match actual: expected %#v\n got %#v\n", expected, conf)
}
// Test success with disabled iss validation
data = map[string]interface{}{
"kubernetes_host": "host",
"kubernetes_ca_cert": testCACert,
"disable_iss_validation": true,
}
req = &logical.Request{
Operation: logical.CreateOperation,
Path: configPath,
Storage: storage,
Data: data,
}
resp, err = b.HandleRequest(context.Background(), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
cert, err = parsePublicKeyPEM([]byte(testRSACert))
if err != nil {
t.Fatal(err)
}
expected = &kubeConfig{
PublicKeys: []crypto.PublicKey{},
PEMKeys: []string{},
Host: "host",
CACert: testCACert,
DisableISSValidation: true,
DisableLocalCAJwt: false,
}
conf, err = b.(*kubeAuthBackend).config(context.Background(), storage)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(expected, conf) {
t.Fatalf("expected did not match actual: expected %#v\n got %#v\n", expected, conf)
}
}
func TestConfig_LocalCaJWT(t *testing.T) {
testCases := map[string]struct {
config map[string]interface{}
setupInClusterFiles bool
expected *kubeConfig
}{
"no CA or JWT, default to local": {
config: map[string]interface{}{
"kubernetes_host": "host",
},
setupInClusterFiles: true,
expected: &kubeConfig{
PublicKeys: []crypto.PublicKey{},
PEMKeys: []string{},
Host: "host",
CACert: testLocalCACert,
TokenReviewerJWT: testLocalJWT,
DisableISSValidation: true,
DisableLocalCAJwt: false,
},
},
"CA set, default to local JWT": {
config: map[string]interface{}{
"kubernetes_host": "host",
"kubernetes_ca_cert": testCACert,
},
setupInClusterFiles: true,
expected: &kubeConfig{
PublicKeys: []crypto.PublicKey{},
PEMKeys: []string{},
Host: "host",
CACert: testCACert,
TokenReviewerJWT: testLocalJWT,
DisableISSValidation: true,
DisableLocalCAJwt: false,
},
},
"JWT set, default to local CA": {
config: map[string]interface{}{
"kubernetes_host": "host",
"token_reviewer_jwt": jwtGoodDataToken,
},
setupInClusterFiles: true,
expected: &kubeConfig{
PublicKeys: []crypto.PublicKey{},
PEMKeys: []string{},
Host: "host",
CACert: testLocalCACert,
TokenReviewerJWT: jwtGoodDataToken,
DisableISSValidation: true,
DisableLocalCAJwt: false,
},
},
"CA and disable local default": {
config: map[string]interface{}{
"kubernetes_host": "host",
"kubernetes_ca_cert": testCACert,
"disable_local_ca_jwt": true,
},
expected: &kubeConfig{
PublicKeys: []crypto.PublicKey{},
PEMKeys: []string{},
Host: "host",
CACert: testCACert,
TokenReviewerJWT: "",
DisableISSValidation: true,
DisableLocalCAJwt: true,
},
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
b, storage := getBackend(t)
if tc.setupInClusterFiles {
cleanup := setupLocalFiles(t, b)
defer cleanup()
}
req := &logical.Request{
Operation: logical.CreateOperation,
Path: configPath,
Storage: storage,
Data: tc.config,
}
resp, err := b.HandleRequest(context.Background(), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
conf, err := b.(*kubeAuthBackend).loadConfig(context.Background(), storage)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(tc.expected, conf) {
t.Fatalf("expected did not match actual: expected %#v\n got %#v\n", tc.expected, conf)
}
})
}
}
func TestConfig_LocalJWTRenewal(t *testing.T) {
b, storage := getBackend(t)
cleanup := setupLocalFiles(t, b)
defer cleanup()
// Create temp file that will be used as token.
f, err := ioutil.TempFile("", "renewed-token")
if err != nil {
t.Error(err)
}
f.Close()
defer os.Remove(f.Name())
currentTime := time.Now()
b.(*kubeAuthBackend).localSATokenReader = newCachingFileReader(f.Name(), jwtReloadPeriod, func() time.Time {
return currentTime
})
token1 := "before-renewal"
token2 := "after-renewal"
// Write initial token to the temp file.
ioutil.WriteFile(f.Name(), []byte(token1), 0o644)
data := map[string]interface{}{
"kubernetes_host": "host",
}
req := &logical.Request{
Operation: logical.CreateOperation,
Path: configPath,
Storage: storage,
Data: data,
}
resp, err := b.HandleRequest(context.Background(), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
// Loading the config will load the initial token file from disk.
conf, err := b.(*kubeAuthBackend).loadConfig(context.Background(), storage)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
// Check that we loaded the initial token.
if conf.TokenReviewerJWT != token1 {
t.Fatalf("got unexpected JWT: expected %#v\n got %#v\n", token1, conf.TokenReviewerJWT)
}
// Write new value to the token file to simulate renewal.
ioutil.WriteFile(f.Name(), []byte(token2), 0o644)
// Load again to check we still got the old cached token from memory.
conf, err = b.(*kubeAuthBackend).loadConfig(context.Background(), storage)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
if conf.TokenReviewerJWT != token1 {
t.Fatalf("got unexpected JWT: expected %#v\n got %#v\n", token1, conf.TokenReviewerJWT)
}
// Advance simulated time for cache to expire
currentTime = currentTime.Add(1 * time.Minute)
// Load again and check we the new renewed token from disk.
conf, err = b.(*kubeAuthBackend).loadConfig(context.Background(), storage)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
if conf.TokenReviewerJWT != token2 {
t.Fatalf("got unexpected JWT: expected %#v\n got %#v\n", token2, conf.TokenReviewerJWT)
}
}
var testLocalCACert string = `-----BEGIN CERTIFICATE-----
MIIDVDCCAjwCCQDFiyFY1M6afTANBgkqhkiG9w0BAQsFADBsMQswCQYDVQQGEwJV
UzETMBEGA1UECAwKV2FzaGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEgMB4GA1UE
CgwXVmF1bHQgVGVzdGluZyBBdXRob3JpdHkxFDASBgNVBAMMC2V4YW1wbGUubmV0
MB4XDTIwMDkxODAxMjkxM1oXDTQ1MDkxODAxMjkxM1owbDELMAkGA1UEBhMCVVMx
EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIDAeBgNVBAoM
F1ZhdWx0IFRlc3RpbmcgQXV0aG9yaXR5MRQwEgYDVQQDDAtleGFtcGxlLm5ldDCC
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALCA9oKv+ESRHX2e/iq1PlGr
zD23/MBS0V+fWQDY0hyEqY98CGwRtF6pEcLEYsreArj5/zznsIevLkNOD+beg43y
WpEJlCPgDhGXI/Oima6ooHVEIMaIKLjK7GrSzAb3rNRGACwrR/u/IKaFl+XJG0qx
g8mOZ3fByaAlIk+shVLUcIedNN1tNR+6/4ZpHg7PDjrZXP4XKrmKPTh4yqfu+BtZ
9IY2oyregqEsGW1/3h1NM+LHGVakTV2d/mwMYHhwoq9Y8BD+PemT5z8TmhH/cIk5
P8Q8ud5/q6YTIJg9TELKebLAeNtRNnNoHeUoRTjiW1MBwNHtgyTTY+H3W/9Dne0C
AwEAATANBgkqhkiG9w0BAQsFAAOCAQEAXmygFkGIBnXxKlsTDiV8RW2iHLgFdZFJ
hcU8UpxZhhaL5JbQl6byfbHjrX31q7ii8uC8FcbW0AEdnEQAb9Ui6a+if7HwXNmI
DTlYl+lMlk9RtWvExw6AEEbg5nCpGaKexm7wJgzYGP9by9pQ7wX/CS7ofCzCK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hGB1zwnPZq39qjY
ySQiGvnjV3fP+N5CTQAwMNe79Xiw31fSoexgceCPJpraWrTOLdCv04SbGDBapMFM
aezBu9jzZm0CNt60jHXWXuHHVPFX6u7ZR8W+RiBvsT8GZ5U6sNs3aN3M9Vym06BL
aSphIw1v+hRlPfnrlJwUnQp158DRgkt/9ncTa/k88KoIoZAbulaiGB4zHxxkbura
GSlgpZzhHSrBDLuXf65GHwwGxSExhgY5AA/n8rumGVvE8IYohS9yg/jOG0xP2WQH
u/ABoYtOyseO+lgElA8R4PB9MtwgN6c/b0xH
-----END CERTIFICATE-----`