1010 AuthenticationConfiguration ,
1111 Configuration ,
1212 JwkConfiguration ,
13+ RHIdentityConfiguration ,
1314 LlamaStackConfiguration ,
1415 ServiceConfiguration ,
1516 UserDataCollection ,
1920 AUTH_MOD_NOOP ,
2021 AUTH_MOD_K8S ,
2122 AUTH_MOD_JWK_TOKEN ,
23+ AUTH_MOD_RH_IDENTITY ,
2224)
2325
2426
@@ -36,6 +38,7 @@ def test_authentication_configuration() -> None:
3638 assert auth_config .skip_tls_verification is False
3739 assert auth_config .k8s_ca_cert_path is None
3840 assert auth_config .k8s_cluster_api is None
41+ assert auth_config .rh_identity_config is None
3942
4043 # try to retrieve JWK configuration
4144 with pytest .raises (
@@ -45,6 +48,92 @@ def test_authentication_configuration() -> None:
4548 _ = auth_config .jwk_configuration
4649
4750
51+ def test_authentication_configuration_rh_identity () -> None :
52+ """Test the AuthenticationConfiguration with RH identity token."""
53+
54+ auth_config = AuthenticationConfiguration (
55+ module = AUTH_MOD_RH_IDENTITY ,
56+ skip_tls_verification = False ,
57+ k8s_ca_cert_path = None ,
58+ k8s_cluster_api = None ,
59+ rh_identity_config = RHIdentityConfiguration (required_entitlements = []),
60+ )
61+ assert auth_config is not None
62+ assert auth_config .module == AUTH_MOD_RH_IDENTITY
63+ assert auth_config .skip_tls_verification is False
64+ assert auth_config .k8s_ca_cert_path is None
65+ assert auth_config .k8s_cluster_api is None
66+ assert auth_config .rh_identity_config is not None
67+
68+
69+ def test_authentication_configuration_rh_identity_default_value () -> None :
70+ """Test the AuthenticationConfiguration with RH identity token."""
71+
72+ auth_config = AuthenticationConfiguration (
73+ module = AUTH_MOD_RH_IDENTITY ,
74+ skip_tls_verification = False ,
75+ k8s_ca_cert_path = None ,
76+ k8s_cluster_api = None ,
77+ rh_identity_config = RHIdentityConfiguration (),
78+ )
79+ assert auth_config is not None
80+ assert auth_config .module == AUTH_MOD_RH_IDENTITY
81+ assert auth_config .skip_tls_verification is False
82+ assert auth_config .k8s_ca_cert_path is None
83+ assert auth_config .k8s_cluster_api is None
84+ assert auth_config .rh_identity_config is not None
85+
86+
87+ def test_authentication_configuration_rh_identity_one_entitlement () -> None :
88+ """Test the AuthenticationConfiguration with RH identity token."""
89+
90+ auth_config = AuthenticationConfiguration (
91+ module = AUTH_MOD_RH_IDENTITY ,
92+ skip_tls_verification = False ,
93+ k8s_ca_cert_path = None ,
94+ k8s_cluster_api = None ,
95+ rh_identity_config = RHIdentityConfiguration (required_entitlements = ["foo" ]),
96+ )
97+ assert auth_config is not None
98+ assert auth_config .module == AUTH_MOD_RH_IDENTITY
99+ assert auth_config .skip_tls_verification is False
100+ assert auth_config .k8s_ca_cert_path is None
101+ assert auth_config .k8s_cluster_api is None
102+ assert auth_config .rh_identity_config is not None
103+
104+
105+ def test_authentication_configuration_rh_identity_more_entitlements () -> None :
106+ """Test the AuthenticationConfiguration with RH identity token."""
107+
108+ auth_config = AuthenticationConfiguration (
109+ module = AUTH_MOD_RH_IDENTITY ,
110+ skip_tls_verification = False ,
111+ k8s_ca_cert_path = None ,
112+ k8s_cluster_api = None ,
113+ rh_identity_config = RHIdentityConfiguration (
114+ required_entitlements = ["foo" , "bar" , "baz" ]
115+ ),
116+ )
117+ assert auth_config is not None
118+ assert auth_config .module == AUTH_MOD_RH_IDENTITY
119+ assert auth_config .skip_tls_verification is False
120+ assert auth_config .k8s_ca_cert_path is None
121+ assert auth_config .k8s_cluster_api is None
122+ assert auth_config .rh_identity_config is not None
123+
124+
125+ def test_authentication_configuration_rh_identity_but_insufficient_config () -> None :
126+ """Test the AuthenticationConfiguration with RH identity token."""
127+
128+ with pytest .raises (ValidationError , match = "RH" ):
129+ AuthenticationConfiguration (
130+ module = AUTH_MOD_RH_IDENTITY ,
131+ skip_tls_verification = False ,
132+ k8s_ca_cert_path = None ,
133+ k8s_cluster_api = None ,
134+ )
135+
136+
48137def test_authentication_configuration_jwk_token () -> None :
49138 """Test the AuthenticationConfiguration with JWK token."""
50139
0 commit comments