@@ -25,23 +25,24 @@ package v1alpha
25
25
import (
26
26
"testing"
27
27
28
+ "github.com/arangodb/kube-arangodb/pkg/util"
28
29
"github.com/stretchr/testify/assert"
29
30
)
30
31
31
32
func TestAuthenticationSpecValidate (t * testing.T ) {
32
33
// Valid
33
- assert .Nil (t , AuthenticationSpec {JWTSecretName : "None" }.Validate (false ))
34
- assert .Nil (t , AuthenticationSpec {JWTSecretName : "foo" }.Validate (false ))
35
- assert .Nil (t , AuthenticationSpec {JWTSecretName : "foo" }.Validate (true ))
34
+ assert .Nil (t , AuthenticationSpec {JWTSecretName : util . NewString ( "None" ) }.Validate (false ))
35
+ assert .Nil (t , AuthenticationSpec {JWTSecretName : util . NewString ( "foo" ) }.Validate (false ))
36
+ assert .Nil (t , AuthenticationSpec {JWTSecretName : util . NewString ( "foo" ) }.Validate (true ))
36
37
37
38
// Not valid
38
- assert .Error (t , AuthenticationSpec {JWTSecretName : "Foo" }.Validate (false ))
39
+ assert .Error (t , AuthenticationSpec {JWTSecretName : util . NewString ( "Foo" ) }.Validate (false ))
39
40
}
40
41
41
42
func TestAuthenticationSpecIsAuthenticated (t * testing.T ) {
42
- assert .False (t , AuthenticationSpec {JWTSecretName : "None" }.IsAuthenticated ())
43
- assert .True (t , AuthenticationSpec {JWTSecretName : "foo" }.IsAuthenticated ())
44
- assert .True (t , AuthenticationSpec {JWTSecretName : "" }.IsAuthenticated ())
43
+ assert .False (t , AuthenticationSpec {JWTSecretName : util . NewString ( "None" ) }.IsAuthenticated ())
44
+ assert .True (t , AuthenticationSpec {JWTSecretName : util . NewString ( "foo" ) }.IsAuthenticated ())
45
+ assert .True (t , AuthenticationSpec {JWTSecretName : util . NewString ( "" ) }.IsAuthenticated ())
45
46
}
46
47
47
48
func TestAuthenticationSpecSetDefaults (t * testing.T ) {
@@ -50,8 +51,8 @@ func TestAuthenticationSpecSetDefaults(t *testing.T) {
50
51
return spec
51
52
}
52
53
53
- assert .Equal (t , "test-jwt" , def (AuthenticationSpec {}).JWTSecretName )
54
- assert .Equal (t , "foo" , def (AuthenticationSpec {JWTSecretName : "foo" }).JWTSecretName )
54
+ assert .Equal (t , "test-jwt" , def (AuthenticationSpec {}).GetJWTSecretName () )
55
+ assert .Equal (t , "foo" , def (AuthenticationSpec {JWTSecretName : util . NewString ( "foo" ) }).GetJWTSecretName () )
55
56
}
56
57
57
58
func TestAuthenticationSpecResetImmutableFields (t * testing.T ) {
@@ -63,35 +64,35 @@ func TestAuthenticationSpecResetImmutableFields(t *testing.T) {
63
64
}{
64
65
// Valid "changes"
65
66
{
66
- AuthenticationSpec {JWTSecretName : "None" },
67
- AuthenticationSpec {JWTSecretName : "None" },
68
- AuthenticationSpec {JWTSecretName : "None" },
67
+ AuthenticationSpec {JWTSecretName : util . NewString ( "None" ) },
68
+ AuthenticationSpec {JWTSecretName : util . NewString ( "None" ) },
69
+ AuthenticationSpec {JWTSecretName : util . NewString ( "None" ) },
69
70
nil ,
70
71
},
71
72
{
72
- AuthenticationSpec {JWTSecretName : "foo" },
73
- AuthenticationSpec {JWTSecretName : "foo" },
74
- AuthenticationSpec {JWTSecretName : "foo" },
73
+ AuthenticationSpec {JWTSecretName : util . NewString ( "foo" ) },
74
+ AuthenticationSpec {JWTSecretName : util . NewString ( "foo" ) },
75
+ AuthenticationSpec {JWTSecretName : util . NewString ( "foo" ) },
75
76
nil ,
76
77
},
77
78
{
78
- AuthenticationSpec {JWTSecretName : "foo" },
79
- AuthenticationSpec {JWTSecretName : "foo2" },
80
- AuthenticationSpec {JWTSecretName : "foo2" },
79
+ AuthenticationSpec {JWTSecretName : util . NewString ( "foo" ) },
80
+ AuthenticationSpec {JWTSecretName : util . NewString ( "foo2" ) },
81
+ AuthenticationSpec {JWTSecretName : util . NewString ( "foo2" ) },
81
82
nil ,
82
83
},
83
84
84
85
// Invalid changes
85
86
{
86
- AuthenticationSpec {JWTSecretName : "foo" },
87
- AuthenticationSpec {JWTSecretName : "None" },
88
- AuthenticationSpec {JWTSecretName : "foo" },
87
+ AuthenticationSpec {JWTSecretName : util . NewString ( "foo" ) },
88
+ AuthenticationSpec {JWTSecretName : util . NewString ( "None" ) },
89
+ AuthenticationSpec {JWTSecretName : util . NewString ( "foo" ) },
89
90
[]string {"test.jwtSecretName" },
90
91
},
91
92
{
92
- AuthenticationSpec {JWTSecretName : "None" },
93
- AuthenticationSpec {JWTSecretName : "foo" },
94
- AuthenticationSpec {JWTSecretName : "None" },
93
+ AuthenticationSpec {JWTSecretName : util . NewString ( "None" ) },
94
+ AuthenticationSpec {JWTSecretName : util . NewString ( "foo" ) },
95
+ AuthenticationSpec {JWTSecretName : util . NewString ( "None" ) },
95
96
[]string {"test.jwtSecretName" },
96
97
},
97
98
}
0 commit comments