@@ -1108,6 +1108,116 @@ var _ = Describe("Keystone controller", func() {
11081108 })
11091109 })
11101110
1111+ When ("A TLS KeystoneAPI is created with an OIDC Federation configuration" , func () {
1112+ BeforeEach (func () {
1113+ spec := GetTLSKeystoneAPISpec ()
1114+ /* serviceOverride := map[string]interface{}{}
1115+ serviceOverride["public"] = map[string]interface{}{
1116+ "endpointURL": "https://keystone-openstack.apps-crc.testing",
1117+ }
1118+ spec["override"] = map[string]interface{}{
1119+ "service": serviceOverride,
1120+ } */
1121+ spec ["oidcFederation" ] = map [string ]interface {}{
1122+ "keystoneFederationIdentityProviderName" : "myidp" ,
1123+ "oidcCacheType" : "memcache" ,
1124+ "oidcClaimDelimiter" : ";" ,
1125+ "oidcClaimPrefix" : "OIDC-" ,
1126+ "oidcClientID" : "client123" ,
1127+ "oidcIntrospectionEndpoint" : "https://idp.example.com/token/introspect" ,
1128+ "oidcPassClaimsAs" : "both" ,
1129+ "oidcPassUserInfoAs" : "claims" ,
1130+ "oidcProviderMetadataURL" : "https://idp.example.com/.well-known/openid-configuration" ,
1131+ "oidcResponseType" : "id_token" ,
1132+ "oidcScope" : "openid email profile" ,
1133+ "remoteIDAttribute" : "HTTP_OIDC_ISS" ,
1134+ }
1135+
1136+ DeferCleanup (k8sClient .Delete , ctx , th .CreateCABundleSecret (caBundleSecretName ))
1137+ DeferCleanup (k8sClient .Delete , ctx , th .CreateCertSecret (internalCertSecretName ))
1138+ DeferCleanup (k8sClient .Delete , ctx , th .CreateCertSecret (publicCertSecretName ))
1139+ DeferCleanup (th .DeleteInstance , CreateKeystoneAPI (keystoneAPIName , spec ))
1140+ DeferCleanup (
1141+ k8sClient .Delete , ctx , CreateKeystoneMessageBusSecret (namespace , "rabbitmq-secret" ))
1142+ DeferCleanup (
1143+ k8sClient .Delete , ctx , CreateKeystoneAPISecret (namespace , SecretName ))
1144+ DeferCleanup (infra .DeleteMemcached , infra .CreateMemcached (namespace , "memcached" , memcachedSpec ))
1145+ DeferCleanup (
1146+ mariadb .DeleteDBService ,
1147+ mariadb .CreateDBService (
1148+ namespace ,
1149+ GetKeystoneAPI (keystoneAPIName ).Spec .DatabaseInstance ,
1150+ corev1.ServiceSpec {
1151+ Ports : []corev1.ServicePort {{Port : 3306 }},
1152+ },
1153+ ),
1154+ )
1155+ mariadb .SimulateMariaDBAccountCompleted (keystoneAccountName )
1156+ mariadb .SimulateMariaDBDatabaseCompleted (keystoneDatabaseName )
1157+ infra .SimulateTransportURLReady (types.NamespacedName {
1158+ Name : fmt .Sprintf ("%s-keystone-transport" , keystoneAPIName .Name ),
1159+ Namespace : namespace ,
1160+ })
1161+ infra .SimulateMemcachedReady (types.NamespacedName {
1162+ Name : "memcached" ,
1163+ Namespace : namespace ,
1164+ })
1165+ th .SimulateJobSuccess (dbSyncJobName )
1166+ th .SimulateJobSuccess (bootstrapJobName )
1167+ th .SimulateDeploymentReplicaReady (deploymentName )
1168+ })
1169+
1170+ /* It("registers LoadBalancer services keystone endpoints", func() {
1171+ instance := keystone.GetKeystoneAPI(keystoneAPIName)
1172+ Expect(instance).NotTo(BeNil())
1173+ Expect(instance.Status.APIEndpoints).To(HaveKeyWithValue("public", "https://keystone-openstack.apps-crc.testing"))
1174+ Expect(instance.Status.APIEndpoints).To(HaveKeyWithValue("internal", "https://keystone-internal."+keystoneAPIName.Namespace+".svc:5000"))
1175+
1176+ th.ExpectCondition(
1177+ keystoneAPIName,
1178+ ConditionGetterFunc(KeystoneConditionGetter),
1179+ condition.ReadyCondition,
1180+ corev1.ConditionTrue,
1181+ )
1182+ }) */
1183+
1184+ It ("should configure OIDC in httpd.conf and keystone.conf" , func () {
1185+ scrt := th .GetSecret (keystoneAPIConfigDataName )
1186+ Expect (scrt ).ShouldNot (BeNil ())
1187+
1188+ // Verify httpd.conf OIDC configuration
1189+ httpdConf := string (scrt .Data ["httpd.conf" ])
1190+ Expect (httpdConf ).Should (ContainSubstring ("OIDCClaimPrefix \" OIDC-\" " ))
1191+ Expect (httpdConf ).Should (ContainSubstring ("OIDCResponseType \" id_token\" " ))
1192+ Expect (httpdConf ).Should (ContainSubstring ("OIDCScope \" openid email profile\" " ))
1193+ Expect (httpdConf ).Should (ContainSubstring ("OIDCProviderMetadataURL https://idp.example.com/.well-known/openid-configuration" ))
1194+ Expect (httpdConf ).Should (ContainSubstring ("OIDCClientID \" client123\" " ))
1195+ Expect (httpdConf ).Should (ContainSubstring ("OIDCClientSecret \" secret123\" " ))
1196+ Expect (httpdConf ).Should (ContainSubstring ("OIDCCryptoPassphrase \" openstack\" " ))
1197+ Expect (httpdConf ).Should (ContainSubstring ("OIDCCClaimDelimiter \" ;\" " ))
1198+ Expect (httpdConf ).Should (ContainSubstring ("OIDCCPassUserInfoAs \" claims\" " ))
1199+ Expect (httpdConf ).Should (ContainSubstring ("OIDCCPassClaimsAs \" both\" " ))
1200+ Expect (httpdConf ).Should (ContainSubstring ("OIDCCacheType \" memcache\" " ))
1201+ Expect (httpdConf ).Should (ContainSubstring ("OIDCRedirectURI \" https://keystone-openstack.apps-crc.testing/v3/auth/OS-FEDERATION/identity_providers/myidp/protocols/openid/websso\" " ))
1202+ Expect (httpdConf ).Should (ContainSubstring ("OIDCRedirectURI \" https://keystone-openstack.apps-crc.testing/v3/auth/OS-FEDERATION/websso/openid\" " ))
1203+ Expect (httpdConf ).Should (ContainSubstring ("LocationMatch \" /v3/auth/OS-FEDERATION/websso/openid\" " ))
1204+ Expect (httpdConf ).Should (ContainSubstring ("LocationMatch \" /v3/auth/OS-FEDERATION/identity_providers/myidp/protocols/openid/websso\" " ))
1205+ Expect (httpdConf ).Should (ContainSubstring ("OIDCAuthClientID \" client123\" " ))
1206+ Expect (httpdConf ).Should (ContainSubstring ("OIDCAuthClientSecret \" secret123\" " ))
1207+ Expect (httpdConf ).Should (ContainSubstring ("OIDCAuthIntrospectionEndpoint \" https://idp.example.com/token/introspect\" " ))
1208+ Expect (httpdConf ).Should (ContainSubstring ("Location ~ \" /v3/auth/OS-FEDERATION/identity_providers/myidp/protocols/openid/auth\" " ))
1209+
1210+ // Verify keystone.conf federation configuration
1211+ keystoneConf := string (scrt .Data ["keystone.conf" ])
1212+ Expect (keystoneConf ).Should (ContainSubstring ("[federation]" ))
1213+ Expect (keystoneConf ).Should (ContainSubstring ("trusted_dashboard=https://keystone-openstack.apps-crc.testing/dashboard/auth/websso/" ))
1214+ Expect (keystoneConf ).Should (ContainSubstring ("[openid]" ))
1215+ Expect (keystoneConf ).Should (ContainSubstring ("remote_id_attribute = HTTP_OIDC_ISS" ))
1216+ Expect (keystoneConf ).Should (ContainSubstring ("[auth]" ))
1217+ Expect (keystoneConf ).Should (ContainSubstring ("methods = password,token,oauth1,mapped,application_credential,openid" ))
1218+ })
1219+ })
1220+
11111221 When ("When FernetMaxActiveKeys is created with a number lower than 3" , func () {
11121222 It ("should fail" , func () {
11131223 err := InterceptGomegaFailure (
@@ -1556,93 +1666,6 @@ var _ = Describe("Keystone controller", func() {
15561666 })
15571667 })
15581668
1559- When ("A KeystoneAPI is created with OIDC Federation configuration" , func () {
1560- BeforeEach (func () {
1561- spec := GetDefaultKeystoneAPISpec ()
1562- spec ["oidcFederation" ] = map [string ]interface {}{
1563- "idpName" : "myidp" ,
1564- "idpURL" : "https://idp.example.com" ,
1565- "idpClientID" : "client123" ,
1566- "idpClientSecret" : "secret123" ,
1567- "idpMetadataURL" : "https://idp.example.com/.well-known/openid-configuration" ,
1568- "idpUserInfoURL" : "https://idp.example.com/userinfo" ,
1569- "idpAuthURL" : "https://idp.example.com/auth" ,
1570- "idpTokenURL" : "https://idp.example.com/token" ,
1571- "idpRemoteIDClaim" : "sub" ,
1572- "idpUsernameClaim" : "preferred_username" ,
1573- "idpScopeClaim" : "scope" ,
1574- "idpRolesClaim" : "roles" ,
1575- "idpDomainName" : "Default" ,
1576- "idpDefaultProject" : "demo" ,
1577- "idpDefaultRole" : "member" ,
1578- "idpScopedTokenGroup" : "oidc" ,
1579- }
1580-
1581- DeferCleanup (
1582- k8sClient .Delete , ctx , CreateKeystoneMessageBusSecret (namespace , "rabbitmq-secret" ))
1583- DeferCleanup (th .DeleteInstance , CreateKeystoneAPI (keystoneAPIName , spec ))
1584- DeferCleanup (
1585- k8sClient .Delete , ctx , CreateKeystoneAPISecret (namespace , SecretName ))
1586- DeferCleanup (infra .DeleteMemcached , infra .CreateMemcached (namespace , "memcached" , memcachedSpec ))
1587- DeferCleanup (
1588- mariadb .DeleteDBService ,
1589- mariadb .CreateDBService (
1590- namespace ,
1591- GetKeystoneAPI (keystoneAPIName ).Spec .DatabaseInstance ,
1592- corev1.ServiceSpec {
1593- Ports : []corev1.ServicePort {{Port : 3306 }},
1594- },
1595- ),
1596- )
1597- mariadb .SimulateMariaDBAccountCompleted (keystoneAccountName )
1598- mariadb .SimulateMariaDBDatabaseCompleted (keystoneDatabaseName )
1599- infra .SimulateTransportURLReady (types.NamespacedName {
1600- Name : fmt .Sprintf ("%s-keystone-transport" , keystoneAPIName .Name ),
1601- Namespace : namespace ,
1602- })
1603- infra .SimulateMemcachedReady (types.NamespacedName {
1604- Name : "memcached" ,
1605- Namespace : namespace ,
1606- })
1607- th .SimulateJobSuccess (dbSyncJobName )
1608- th .SimulateJobSuccess (bootstrapJobName )
1609- th .SimulateDeploymentReplicaReady (deploymentName )
1610- })
1611-
1612- It ("should configure OIDC in httpd.conf and keystone.conf" , func () {
1613- scrt := th .GetSecret (keystoneAPIConfigDataName )
1614- Expect (scrt ).ShouldNot (BeNil ())
1615-
1616- // Verify httpd.conf OIDC configuration
1617- httpdConf := string (scrt .Data ["httpd.conf" ])
1618- Expect (httpdConf ).Should (ContainSubstring ("LoadModule auth_openidc_module modules/mod_auth_openidc.so" ))
1619- Expect (httpdConf ).Should (ContainSubstring ("OIDCProviderMetadataURL https://idp.example.com/.well-known/openid-configuration" ))
1620- Expect (httpdConf ).Should (ContainSubstring ("OIDCClientID client123" ))
1621- Expect (httpdConf ).Should (ContainSubstring ("OIDCClientSecret secret123" ))
1622- Expect (httpdConf ).Should (ContainSubstring ("OIDCRedirectURI https://keystone-public." ))
1623- Expect (httpdConf ).Should (ContainSubstring ("/v3/OS-FEDERATION/identity_providers/myidp/protocols/openid/auth" ))
1624- Expect (httpdConf ).Should (ContainSubstring ("OIDCRemoteUserClaim preferred_username" ))
1625- Expect (httpdConf ).Should (ContainSubstring ("OIDCProviderTokenEndpointAuth client_secret_basic" ))
1626- Expect (httpdConf ).Should (ContainSubstring ("OIDCScope \" openid profile email\" " ))
1627-
1628- // Verify keystone.conf federation configuration
1629- keystoneConf := string (scrt .Data ["keystone.conf" ])
1630- Expect (keystoneConf ).Should (ContainSubstring ("[auth]" ))
1631- Expect (keystoneConf ).Should (ContainSubstring ("methods = password,token,oauth1,openid" ))
1632- Expect (keystoneConf ).Should (ContainSubstring ("[federation]" ))
1633- Expect (keystoneConf ).Should (ContainSubstring ("remote_id_attribute = HTTP_OIDC_ISS" ))
1634- Expect (keystoneConf ).Should (ContainSubstring ("[openid]" ))
1635- Expect (keystoneConf ).Should (ContainSubstring ("remote_id_claim = sub" ))
1636- Expect (keystoneConf ).Should (ContainSubstring ("username_claim = preferred_username" ))
1637- Expect (keystoneConf ).Should (ContainSubstring ("scope_claim = scope" ))
1638- Expect (keystoneConf ).Should (ContainSubstring ("roles_claim = roles" ))
1639- Expect (keystoneConf ).Should (ContainSubstring ("domain_name = Default" ))
1640- Expect (keystoneConf ).Should (ContainSubstring ("default_project = demo" ))
1641- Expect (keystoneConf ).Should (ContainSubstring ("default_role = member" ))
1642- Expect (keystoneConf ).Should (ContainSubstring ("scoped_token_group = oidc" ))
1643- })
1644- })
1645-
16461669 // Run MariaDBAccount suite tests. these are pre-packaged ginkgo tests
16471670 // that exercise standard account create / update patterns that should be
16481671 // common to all controllers that ensure MariaDBAccount CRs.
0 commit comments