@@ -20,6 +20,8 @@ import (
20
20
"strings"
21
21
"testing"
22
22
23
+ "github.com/oracle/oci-go-sdk/v65/common"
24
+
23
25
"github.com/onsi/gomega"
24
26
. "github.com/onsi/gomega"
25
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -79,6 +81,85 @@ func TestOCIManagedControlPlane_ValidateCreate(t *testing.T) {
79
81
},
80
82
expectErr : false ,
81
83
},
84
+ {
85
+ name : "OpenIdConnectAuthEnabledWithValidConfig" ,
86
+ c : & OCIManagedControlPlane {
87
+ Spec : OCIManagedControlPlaneSpec {
88
+ ClusterType : EnhancedClusterType ,
89
+ ClusterOption : ClusterOptions {
90
+ OpenIdConnectTokenAuthenticationConfig : & OpenIDConnectTokenAuthenticationConfig {
91
+ IsOpenIdConnectAuthEnabled : * common .Bool (true ),
92
+ ClientId : common .String ("client-id" ),
93
+ IssuerUrl : common .String ("issuer-url" ),
94
+ },
95
+ },
96
+ },
97
+ },
98
+ expectErr : false ,
99
+ },
100
+ {
101
+ name : "OpenIdConnectAuthEnabledWithInvalidClusterType" ,
102
+ c : & OCIManagedControlPlane {
103
+ Spec : OCIManagedControlPlaneSpec {
104
+ ClusterType : BasicClusterType ,
105
+ ClusterOption : ClusterOptions {
106
+ OpenIdConnectTokenAuthenticationConfig : & OpenIDConnectTokenAuthenticationConfig {
107
+ IsOpenIdConnectAuthEnabled : * common .Bool (true ),
108
+ ClientId : common .String ("client-id" ),
109
+ IssuerUrl : common .String ("issuer-url" ),
110
+ },
111
+ },
112
+ },
113
+ },
114
+ errorMgsShouldContain : "ClusterType needs to be set to ENHANCED_CLUSTER for OpenIdConnectTokenAuthenticationConfig to be enabled." ,
115
+ expectErr : true ,
116
+ },
117
+ {
118
+ name : "OpenIdConnectAuthEnabledWithMissingClientId" ,
119
+ c : & OCIManagedControlPlane {
120
+ Spec : OCIManagedControlPlaneSpec {
121
+ ClusterType : EnhancedClusterType ,
122
+ ClusterOption : ClusterOptions {
123
+ OpenIdConnectTokenAuthenticationConfig : & OpenIDConnectTokenAuthenticationConfig {
124
+ IsOpenIdConnectAuthEnabled : * common .Bool (true ),
125
+ IssuerUrl : common .String ("issuer-url" ),
126
+ },
127
+ },
128
+ },
129
+ },
130
+ errorMgsShouldContain : "ClientId cannot be empty when OpenIdConnectAuth is enabled." ,
131
+ expectErr : true ,
132
+ },
133
+ {
134
+ name : "OpenIdConnectAuthEnabledWithMissingIssuerUrl" ,
135
+ c : & OCIManagedControlPlane {
136
+ Spec : OCIManagedControlPlaneSpec {
137
+ ClusterType : EnhancedClusterType ,
138
+ ClusterOption : ClusterOptions {
139
+ OpenIdConnectTokenAuthenticationConfig : & OpenIDConnectTokenAuthenticationConfig {
140
+ IsOpenIdConnectAuthEnabled : * common .Bool (true ),
141
+ ClientId : common .String ("client-id" ),
142
+ },
143
+ },
144
+ },
145
+ },
146
+ errorMgsShouldContain : "IssuerUrl cannot be empty when OpenIdConnectAuth is enabled." ,
147
+ expectErr : true ,
148
+ },
149
+ {
150
+ name : "OpenIdConnectAuthDisabled" ,
151
+ c : & OCIManagedControlPlane {
152
+ Spec : OCIManagedControlPlaneSpec {
153
+ ClusterType : BasicClusterType ,
154
+ ClusterOption : ClusterOptions {
155
+ OpenIdConnectTokenAuthenticationConfig : & OpenIDConnectTokenAuthenticationConfig {
156
+ IsOpenIdConnectAuthEnabled : * common .Bool (false ),
157
+ },
158
+ },
159
+ },
160
+ },
161
+ expectErr : false ,
162
+ },
82
163
}
83
164
for _ , test := range tests {
84
165
t .Run (test .name , func (t * testing.T ) {
0 commit comments