Skip to content

Commit 2dfa5fa

Browse files
committed
test: Add CRD roundtrip test data
1 parent 02f2b0a commit 2dfa5fa

1 file changed

Lines changed: 208 additions & 2 deletions

File tree

  • rust/operator-binary/src/crd

rust/operator-binary/src/crd/mod.rs

Lines changed: 208 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,19 +457,225 @@ impl HasStatusCondition for v1alpha2::OpaCluster {
457457

458458
#[cfg(test)]
459459
mod tests {
460+
use indoc::formatdoc;
460461
use stackable_operator::versioned::test_utils::RoundtripTestData;
461462

462463
use super::{v1alpha1, v1alpha2};
463464

464465
impl RoundtripTestData for v1alpha1::OpaClusterSpec {
465466
fn roundtrip_test_data() -> Vec<Self> {
466-
vec![]
467+
let user_info_fetcher_sections = vec![
468+
r#"
469+
userInfo:
470+
backend:
471+
experimentalXfscAas:
472+
hostname: aas.default.svc.cluster.local
473+
port: 5000
474+
"#,
475+
r#"
476+
userInfo:
477+
backend:
478+
experimentalActiveDirectory:
479+
ldapServer: sble-addc.sble.test
480+
baseDistinguishedName: DC=sble,DC=test
481+
customAttributeMappings:
482+
country: c
483+
kerberosSecretClassName: kerberos-ad
484+
tls:
485+
verification:
486+
server:
487+
caCert:
488+
secretClass: tls-ad
489+
cache:
490+
entryTimeToLive: 60s
491+
"#,
492+
r#"
493+
userInfo:
494+
backend:
495+
keycloak:
496+
hostname: keycloak.default.svc.cluster.local
497+
port: 8443
498+
tls:
499+
verification:
500+
server:
501+
caCert:
502+
secretClass: keycloak-tls
503+
clientCredentialsSecret: user-info-fetcher-client-credentials
504+
adminRealm: my-dataspace
505+
userRealm: my-dataspace
506+
"#,
507+
r#"
508+
userInfo:
509+
backend:
510+
experimentalOpenLdap:
511+
hostname: test-openldap.default.svc.cluster.local
512+
port: 1636
513+
searchBase: ou=users,dc=example,dc=org
514+
bindCredentials:
515+
secretClass: ldap-bind-test
516+
groupsSearchBase: ou=groups,dc=example,dc=org
517+
customAttributeMappings:
518+
hdir: homeDirectory
519+
displayName: cn
520+
surname: sn
521+
tls:
522+
verification:
523+
server:
524+
caCert:
525+
secretClass: ldap-tls-test
526+
cache:
527+
entryTimeToLive: 60s
528+
"#,
529+
r#"
530+
userInfo:
531+
backend:
532+
# Note the experimentalEntra vs entra here!
533+
experimentalEntra:
534+
tenantId: 00000000-0000-0000-0000-000000000000
535+
clientCredentialsSecret: user-info-fetcher-client-credentials
536+
"#,
537+
];
538+
user_info_fetcher_sections
539+
.into_iter()
540+
.map(test_opa_cluster_yaml)
541+
.map(|yaml| {
542+
println!("{}", &yaml);
543+
stackable_operator::utils::yaml_from_str_singleton_map(&yaml)
544+
.expect("Failed to parse OpaClusterSpec YAML")
545+
})
546+
.collect()
467547
}
468548
}
469549

470550
impl RoundtripTestData for v1alpha2::OpaClusterSpec {
471551
fn roundtrip_test_data() -> Vec<Self> {
472-
vec![]
552+
let user_info_fetcher_sections = vec![
553+
r#"
554+
userInfo:
555+
backend:
556+
experimentalXfscAas:
557+
hostname: aas.default.svc.cluster.local
558+
port: 5000
559+
"#,
560+
r#"
561+
userInfo:
562+
backend:
563+
experimentalActiveDirectory:
564+
ldapServer: sble-addc.sble.test
565+
baseDistinguishedName: DC=sble,DC=test
566+
customAttributeMappings:
567+
country: c
568+
kerberosSecretClassName: kerberos-ad
569+
tls:
570+
verification:
571+
server:
572+
caCert:
573+
secretClass: tls-ad
574+
cache:
575+
entryTimeToLive: 60s
576+
"#,
577+
r#"
578+
userInfo:
579+
backend:
580+
keycloak:
581+
hostname: keycloak.default.svc.cluster.local
582+
port: 8443
583+
tls:
584+
verification:
585+
server:
586+
caCert:
587+
secretClass: keycloak-tls
588+
clientCredentialsSecret: user-info-fetcher-client-credentials
589+
adminRealm: my-dataspace
590+
userRealm: my-dataspace
591+
"#,
592+
r#"
593+
userInfo:
594+
backend:
595+
experimentalOpenLdap:
596+
hostname: test-openldap.default.svc.cluster.local
597+
port: 1636
598+
searchBase: ou=users,dc=example,dc=org
599+
bindCredentials:
600+
secretClass: ldap-bind-test
601+
groupsSearchBase: ou=groups,dc=example,dc=org
602+
customAttributeMappings:
603+
hdir: homeDirectory
604+
displayName: cn
605+
surname: sn
606+
tls:
607+
verification:
608+
server:
609+
caCert:
610+
secretClass: ldap-tls-test
611+
cache:
612+
entryTimeToLive: 60s
613+
"#,
614+
r#"
615+
userInfo:
616+
backend:
617+
# Note the experimentalEntra vs entra here!
618+
entra:
619+
tenantId: 00000000-0000-0000-0000-000000000000
620+
clientCredentialsSecret: user-info-fetcher-client-credentials
621+
"#,
622+
];
623+
user_info_fetcher_sections
624+
.into_iter()
625+
.map(test_opa_cluster_yaml)
626+
.map(|yaml| {
627+
println!("{}", &yaml);
628+
stackable_operator::utils::yaml_from_str_singleton_map(&yaml)
629+
.expect("Failed to parse OpaClusterSpec YAML")
630+
})
631+
.collect()
632+
}
633+
}
634+
635+
fn test_opa_cluster_yaml(user_info_fetcher_section: &str) -> String {
636+
formatdoc! {
637+
r#"
638+
image:
639+
productVersion: 1.2.3
640+
pullPolicy: IfNotPresent
641+
clusterOperation:
642+
stopped: false
643+
reconciliationPaused: false
644+
clusterConfig:
645+
tls:
646+
serverSecretClass: my-tls
647+
vectorAggregatorConfigMapName: vector-aggregator-discovery
648+
{user_info_fetcher_section}
649+
servers:
650+
config:
651+
logging:
652+
enableVectorAgent: true
653+
configOverrides:
654+
config.json:
655+
jsonMergePatch:
656+
bundles:
657+
stackable:
658+
polling:
659+
min_delay_seconds: 3
660+
max_delay_seconds: 7
661+
default_decision: test/hello
662+
envOverrides:
663+
SERVER_ROLE_LEVEL_ENV_VAR: SERVER_ROLE_LEVEL_ENV_VAR
664+
roleGroups:
665+
default:
666+
configOverrides:
667+
config.json:
668+
jsonMergePatch:
669+
bundles:
670+
stackable:
671+
polling:
672+
max_delay_seconds: 5
673+
labels:
674+
rolegroup: default
675+
envOverrides:
676+
SERVER_ROLE_GROUP_LEVEL_ENV_VAR: SERVER_ROLE_GROUP_LEVEL_ENV_VAR
677+
replicas: 1
678+
"#
473679
}
474680
}
475681
}

0 commit comments

Comments
 (0)