@@ -199,6 +199,7 @@ func Test_ValidateAndCombineConfig(t *testing.T) {
199
199
- Use --venafi-connection for the Venafi Cloud VenafiConnection mode.
200
200
- Use --credentials-file alone if you want to use the Jetstack Secure OAuth mode.
201
201
- Use --api-token if you want to use the Jetstack Secure API Token mode.
202
+ - Use --machine-hub if you want to use the MachineHub mode.
202
203
- Use --output-path or output-path in the config file for Local File mode.` ))
203
204
assert .Nil (t , cl )
204
205
})
@@ -617,6 +618,40 @@ func Test_ValidateAndCombineConfig(t *testing.T) {
617
618
assert .Equal (t , VenafiCloudVenafiConnection , got .OutputMode )
618
619
})
619
620
621
+ t .Run ("--machine-hub selects MachineHub mode" , func (t * testing.T ) {
622
+ t .Setenv ("POD_NAMESPACE" , "venafi" )
623
+ t .Setenv ("KUBECONFIG" , withFile (t , fakeKubeconfig ))
624
+ t .Setenv ("ARK_PLATFORM_DOMAIN" , "cyberark.cloud" )
625
+ t .Setenv ("ARK_SUBDOMAIN" , "tlspk" )
626
+ t .
Setenv (
"ARK_USERNAME" ,
"[email protected] " )
627
+ t .Setenv ("ARK_SECRET" , "test-secret" )
628
+ got , cl , err := ValidateAndCombineConfig (discardLogs (),
629
+ withConfig ("" ),
630
+ withCmdLineFlags ("--period" , "1m" , "--machine-hub" ))
631
+ require .NoError (t , err )
632
+ assert .Equal (t , MachineHub , got .OutputMode )
633
+ assert .IsType (t , & client.CyberArkClient {}, cl )
634
+ })
635
+
636
+ t .Run ("--machine-hub without required environment variables" , func (t * testing.T ) {
637
+ t .Setenv ("POD_NAMESPACE" , "venafi" )
638
+ t .Setenv ("KUBECONFIG" , withFile (t , fakeKubeconfig ))
639
+ t .Setenv ("ARK_PLATFORM_DOMAIN" , "" )
640
+ t .Setenv ("ARK_SUBDOMAIN" , "" )
641
+ t .Setenv ("ARK_USERNAME" , "" )
642
+ t .Setenv ("ARK_SECRET" , "" )
643
+ got , cl , err := ValidateAndCombineConfig (discardLogs (),
644
+ withConfig ("" ),
645
+ withCmdLineFlags ("--period" , "1m" , "--machine-hub" ))
646
+ assert .Equal (t , CombinedConfig {}, got )
647
+ assert .Nil (t , cl )
648
+ assert .EqualError (t , err , testutil .Undent (`
649
+ validating creds: failed loading config using the MachineHub mode: 1 error occurred:
650
+ * missing environment variables: ARK_PLATFORM_DOMAIN, ARK_SUBDOMAIN, ARK_USERNAME, ARK_SECRET
651
+
652
+ ` ))
653
+ })
654
+
620
655
t .Run ("argument: --output-file selects local file mode" , func (t * testing.T ) {
621
656
log , gotLog := recordLogs (t )
622
657
got , outputClient , err := ValidateAndCombineConfig (log ,
0 commit comments