@@ -308,7 +308,10 @@ mod tests {
308308
309309 use indoc:: formatdoc;
310310 use rstest:: rstest;
311- use stackable_operator:: crd:: authentication:: { ldap, oidc} ;
311+ use stackable_operator:: {
312+ crd:: authentication:: { ldap, oidc} ,
313+ time:: Duration ,
314+ } ;
312315
313316 use crate :: {
314317 config:: add_airflow_config,
@@ -317,7 +320,7 @@ mod tests {
317320 AirflowAuthenticationClassResolved , AirflowClientAuthenticationDetailsResolved ,
318321 FlaskRolesSyncMoment , default_user_registration,
319322 } ,
320- authorization:: AirflowAuthorizationResolved ,
323+ authorization:: { AirflowAuthorizationResolved , OpaConfigResolved } ,
321324 } ,
322325 } ;
323326
@@ -529,4 +532,41 @@ mod tests {
529532 result
530533 ) ;
531534 }
535+
536+ #[ test]
537+ fn test_opa_config ( ) {
538+ let authentication_config = AirflowClientAuthenticationDetailsResolved {
539+ authentication_classes_resolved : vec ! [ ] ,
540+ user_registration : true ,
541+ user_registration_role : "User" . to_string ( ) ,
542+ sync_roles_at : FlaskRolesSyncMoment :: Registration ,
543+ } ;
544+
545+ let authorization_config = AirflowAuthorizationResolved {
546+ opa : Some ( OpaConfigResolved {
547+ connection_string : "http://opa:8081/v1/data/airflow" . to_string ( ) ,
548+ cache_entry_time_to_live : Duration :: from_secs ( 30 ) ,
549+ cache_max_entries : 1000 ,
550+ } ) ,
551+ } ;
552+
553+ let mut result = BTreeMap :: new ( ) ;
554+ add_airflow_config (
555+ & mut result,
556+ & authentication_config,
557+ & authorization_config,
558+ TEST_AIRFLOW_VERSION ,
559+ )
560+ . expect ( "Ok" ) ;
561+
562+ assert_eq ! (
563+ BTreeMap :: from( [
564+ ( "AUTH_ROLES_SYNC_AT_LOGIN" . into( ) , "false" . into( ) ) ,
565+ ( "AUTH_TYPE" . into( ) , "AUTH_DB" . into( ) ) ,
566+ ( "AUTH_USER_REGISTRATION" . into( ) , "true" . into( ) ) ,
567+ ( "AUTH_USER_REGISTRATION_ROLE" . into( ) , "User" . into( ) )
568+ ] ) ,
569+ result
570+ ) ;
571+ }
532572}
0 commit comments