@@ -547,31 +547,10 @@ var _ = Describe("ConfigMap handling", func() {
547
547
"LDAP_RECURSIVE_SEARCH" ,
548
548
[]string {"LDAP_RECURSIVE_SEARCH" },
549
549
},
550
- {
551
- "CLAIMS_SUPPORTED" ,
552
- []string {
553
- "CLAIMS_SUPPORTED" ,
554
- "CLAIMS_MAP" ,
555
- "SCOPE_CLAIM" ,
556
- "BOOTSTRAP_USERID" ,
557
- },
558
- },
559
550
{
560
551
"DEFAULT_LOGIN" ,
561
552
[]string {"DEFAULT_LOGIN" },
562
553
},
563
- {
564
- "PROVIDER_ISSUER_URL" ,
565
- []string {
566
- "PROVIDER_ISSUER_URL" ,
567
- },
568
- },
569
- {
570
- "PREFERRED_LOGIN" ,
571
- []string {
572
- "PREFERRED_LOGIN" ,
573
- },
574
- },
575
554
{
576
555
"DB_CONNECT_TIMEOUT" ,
577
556
[]string {
@@ -654,7 +633,46 @@ var _ = Describe("ConfigMap handling", func() {
654
633
}
655
634
656
635
for _ , test := range updateOnNotSetKeys {
657
- observed := getObserved ()
636
+ observed := & corev1.ConfigMap {}
637
+ Expect (generateAuthIdpConfigMap (ctx , r .Client , authCR , ibmcloudClusterInfo , observed )).
638
+ To (Succeed ())
639
+ generated := & corev1.ConfigMap {}
640
+ err := generateAuthIdpConfigMap (ctx , r .Client , authCR , ibmcloudClusterInfo , generated )
641
+ Expect (err ).NotTo (HaveOccurred ())
642
+ updated , err = updatePlatformAuthIDP (observed , generated )
643
+ Expect (err ).ToNot (HaveOccurred ())
644
+ Expect (updated ).To (BeFalse ())
645
+ setDummyData (test .primaryKey , test .keys , observed )
646
+ updated , err = updatePlatformAuthIDP (observed , generated )
647
+ Expect (err ).NotTo (HaveOccurred ())
648
+ Expect (updated ).To (BeTrue ())
649
+ for _ , k := range test .keys {
650
+ Expect (observed .Data [k ]).To (Equal (generated .Data [k ]))
651
+ }
652
+ }
653
+ })
654
+
655
+ It ("sets fields when the values do not match the expected value" , func () {
656
+ updateOnNotUpToDate := []struct {
657
+ primaryKey string
658
+ keys []string
659
+ }{
660
+ {
661
+ "DEFAULT_LOGIN" ,
662
+ []string {"DEFAULT_LOGIN" },
663
+ },
664
+ }
665
+
666
+ setDummyData := func (pkey string , keys []string , o * corev1.ConfigMap ) {
667
+ dummyValue := "dummy"
668
+ for _ , k := range keys {
669
+ o .Data [k ] = dummyValue
670
+ }
671
+ }
672
+ for _ , test := range updateOnNotUpToDate {
673
+ observed := & corev1.ConfigMap {}
674
+ Expect (generateAuthIdpConfigMap (ctx , r .Client , authCR , ibmcloudClusterInfo , observed )).
675
+ To (Succeed ())
658
676
generated := & corev1.ConfigMap {}
659
677
err := generateAuthIdpConfigMap (ctx , r .Client , authCR , ibmcloudClusterInfo , generated )
660
678
Expect (err ).NotTo (HaveOccurred ())
@@ -694,7 +712,9 @@ var _ = Describe("ConfigMap handling", func() {
694
712
})
695
713
696
714
It ("replaces value in OS_TOKEN_LENGTH only when it is set to 45" , func () {
697
- observed := getObserved ()
715
+ observed := & corev1.ConfigMap {}
716
+ Expect (generateAuthIdpConfigMap (ctx , r .Client , authCR , ibmcloudClusterInfo , observed )).
717
+ To (Succeed ())
698
718
// Set the keys in observed to contain localhost IP
699
719
k := "OS_TOKEN_LENGTH"
700
720
observed .Data [k ] = "24"
@@ -711,6 +731,45 @@ var _ = Describe("ConfigMap handling", func() {
711
731
Expect (updated ).To (BeTrue ())
712
732
Expect (observed .Data [k ]).To (Equal (generated .Data [k ]))
713
733
})
734
+
735
+ It ("always replaces certain values if they differ" , func () {
736
+ updateAlways := []string {
737
+ "ROKS_URL" ,
738
+ "ROKS_USER_PREFIX" ,
739
+ "ROKS_ENABLED" ,
740
+ "BOOTSTRAP_USERID" ,
741
+ "CLAIMS_SUPPORTED" ,
742
+ "CLAIMS_MAP" ,
743
+ "SCOPE_CLAIM" ,
744
+ "NONCE_ENABLED" ,
745
+ "PREFERRED_LOGIN" ,
746
+ "OIDC_ISSUER_URL" ,
747
+ "PROVIDER_ISSUER_URL" ,
748
+ "CLUSTER_NAME" ,
749
+ }
750
+
751
+ setDummyData := func (k string , o * corev1.ConfigMap ) {
752
+ dummyValue := "dummy"
753
+ o .Data [k ] = dummyValue
754
+ }
755
+ for _ , test := range updateAlways {
756
+ observed := getObserved ()
757
+ Expect (generateAuthIdpConfigMap (ctx , r .Client , authCR , ibmcloudClusterInfo , observed )).
758
+ To (Succeed ())
759
+ generated := & corev1.ConfigMap {}
760
+ err := generateAuthIdpConfigMap (ctx , r .Client , authCR , ibmcloudClusterInfo , generated )
761
+ Expect (err ).NotTo (HaveOccurred ())
762
+ updated , err = updatePlatformAuthIDP (observed , generated )
763
+ Expect (err ).ToNot (HaveOccurred ())
764
+ Expect (updated ).To (BeFalse ())
765
+ setDummyData (test , observed )
766
+ Expect (observed .Data [test ]).To (Equal ("dummy" ))
767
+ updated , err = updatePlatformAuthIDP (observed , generated )
768
+ Expect (err ).NotTo (HaveOccurred ())
769
+ Expect (updated ).To (BeTrue ())
770
+ Expect (observed .Data [test ]).To (Equal (generated .Data [test ]))
771
+ }
772
+ })
714
773
})
715
774
716
775
Describe ("oauth-client-map handling" , func () {
0 commit comments