@@ -45,11 +45,12 @@ type oidcProviderClient interface {
4545func testOIDCProviderConfig (t * testing.T , client oidcProviderClient ) {
4646 id := randomOIDCProviderID ()
4747 want := & auth.OIDCProviderConfig {
48- ID : id ,
49- DisplayName : "OIDC_DISPLAY_NAME" ,
50- Enabled : true ,
51- ClientID : "OIDC_CLIENT_ID" ,
52- Issuer : "https://oidc.com/issuer" ,
48+ ID : id ,
49+ DisplayName : "OIDC_DISPLAY_NAME" ,
50+ Enabled : true ,
51+ ClientID : "OIDC_CLIENT_ID" ,
52+ Issuer : "https://oidc.com/issuer" ,
53+ IDTokenResponseType : true ,
5354 }
5455
5556 req := (& auth.OIDCProviderConfigToCreate {}).
@@ -117,10 +118,11 @@ func testOIDCProviderConfig(t *testing.T, client oidcProviderClient) {
117118
118119 t .Run ("UpdateOIDCProviderConfig()" , func (t * testing.T ) {
119120 want = & auth.OIDCProviderConfig {
120- ID : id ,
121- DisplayName : "UPDATED_OIDC_DISPLAY_NAME" ,
122- ClientID : "UPDATED_OIDC_CLIENT_ID" ,
123- Issuer : "https://oidc.com/updated_issuer" ,
121+ ID : id ,
122+ DisplayName : "UPDATED_OIDC_DISPLAY_NAME" ,
123+ ClientID : "UPDATED_OIDC_CLIENT_ID" ,
124+ Issuer : "https://oidc.com/updated_issuer" ,
125+ IDTokenResponseType : true ,
124126 }
125127 req := (& auth.OIDCProviderConfigToUpdate {}).
126128 DisplayName ("UPDATED_OIDC_DISPLAY_NAME" ).
@@ -137,6 +139,49 @@ func testOIDCProviderConfig(t *testing.T, client oidcProviderClient) {
137139 }
138140 })
139141
142+ t .Run ("UpdateOIDCProviderConfig() should be rejected with invalid oauth response type" , func (t * testing.T ) {
143+ req := (& auth.OIDCProviderConfigToUpdate {}).
144+ DisplayName ("UPDATED_OIDC_DISPLAY_NAME" ).
145+ Enabled (false ).
146+ ClientID ("UPDATED_OIDC_CLIENT_ID" ).
147+ Issuer ("https://oidc.com/updated_issuer" ).
148+ IDTokenResponseType (false ).
149+ CodeResponseType (false ).
150+ ClientSecret ("CLIENT_SECRET" )
151+ _ , err := client .UpdateOIDCProviderConfig (context .Background (), id , req )
152+ if err == nil {
153+ t .Fatalf ("UpdateOIDCProviderConfig(invalid_oauth_response_type) error nil; want not nil" )
154+ }
155+
156+ if err .Error () != "At least one response type must be returned" {
157+ t .Errorf (
158+ "UpdateOIDCProviderConfig(invalid_oauth_response_type) returned an error of '%s'; " +
159+ "expected 'At least one response type must be returned'" ,
160+ err .Error ())
161+ }
162+ })
163+
164+ t .Run ("UpdateOIDCProviderConfig() should be rejected code flow with no client secret" , func (t * testing.T ) {
165+ req := (& auth.OIDCProviderConfigToUpdate {}).
166+ DisplayName ("UPDATED_OIDC_DISPLAY_NAME" ).
167+ Enabled (false ).
168+ ClientID ("UPDATED_OIDC_CLIENT_ID" ).
169+ Issuer ("https://oidc.com/updated_issuer" ).
170+ IDTokenResponseType (false ).
171+ CodeResponseType (true )
172+ _ , err := client .UpdateOIDCProviderConfig (context .Background (), id , req )
173+ if err == nil {
174+ t .Fatalf ("UpdateOIDCProviderConfig(code_flow_with_no_client_secret) error nil; want not nil" )
175+ }
176+
177+ if err .Error () != "Client Secret must not be empty for Code Response Type" {
178+ t .Errorf (
179+ "UpdateOIDCProviderConfig(code_flow_with_no_client_secret) returned an error of '%s'; " +
180+ "expected 'Client Secret must not be empty for Code Response Type'" ,
181+ err .Error ())
182+ }
183+ })
184+
140185 t .Run ("DeleteOIDCProviderConfig()" , func (t * testing.T ) {
141186 if err := client .DeleteOIDCProviderConfig (context .Background (), id ); err != nil {
142187 t .Fatalf ("DeleteOIDCProviderConfig() = %v" , err )
0 commit comments