@@ -574,6 +574,54 @@ func TestGetAuthEnv(t *testing.T) {
574
574
}
575
575
},
576
576
},
577
+ {
578
+ name : "valid request with MSIAuthTypeAddsIdentityEnv" ,
579
+ testFunc : func (t * testing.T ) {
580
+ d := NewFakeDriver ()
581
+ d .cloud = & storage.AccountRepo {}
582
+ d .cloud .Config .AzureAuthConfig = azclient.AzureAuthConfig {
583
+ UserAssignedIdentityID : "unit-test-identity-id" ,
584
+ }
585
+
586
+ attrib := map [string ]string {
587
+ subscriptionIDField : "subID" ,
588
+ resourceGroupField : "rg" ,
589
+ storageAccountField : "accountname" ,
590
+ storageAccountNameField : "accountname" ,
591
+ secretNameField : "secretName" ,
592
+ secretNamespaceField : "sNS" ,
593
+ containerNameField : "containername" ,
594
+ mountWithWITokenField : "false" ,
595
+ pvcNamespaceKey : "pvcNSKey" ,
596
+ getAccountKeyFromSecretField : "false" ,
597
+ storageAuthTypeField : storageAuthTypeMSI ,
598
+ msiEndpointField : "msiEndpoint" ,
599
+ getLatestAccountKeyField : "true" ,
600
+ }
601
+ secret := make (map [string ]string )
602
+ volumeID := "rg#f5713de20cde511e8ba4900#pvc-fuse-dynamic-17e43f84-f474-11e8-acd0-000d3a00df41"
603
+ ctrl := gomock .NewController (t )
604
+ defer ctrl .Finish ()
605
+ mockStorageAccountsClient := mock_accountclient .NewMockInterface (ctrl )
606
+ d .cloud .ComputeClientFactory = mock_azclient .NewMockClientFactory (ctrl )
607
+ d .cloud .ComputeClientFactory .(* mock_azclient.MockClientFactory ).EXPECT ().GetAccountClient ().Return (mockStorageAccountsClient ).AnyTimes ()
608
+ s := "unit-test"
609
+ accountkey := armstorage.AccountKey {Value : & s }
610
+ list := []* armstorage.AccountKey {& accountkey }
611
+ mockStorageAccountsClient .EXPECT ().ListKeys (gomock .Any (), gomock .Any (), gomock .Any ()).Return (list , nil ).AnyTimes ()
612
+ d .cloud .ComputeClientFactory .(* mock_azclient.MockClientFactory ).EXPECT ().GetAccountClientForSub (gomock .Any ()).Return (mockStorageAccountsClient , nil ).AnyTimes ()
613
+ _ , _ , _ , _ , authEnv , err := d .GetAuthEnv (context .TODO (), volumeID , "" , attrib , secret )
614
+ assert .NoError (t , err )
615
+ found := false
616
+ for _ , env := range authEnv {
617
+ if env == "AZURE_STORAGE_IDENTITY_CLIENT_ID=unit-test-identity-id" {
618
+ found = true
619
+ break
620
+ }
621
+ }
622
+ assert .True (t , found , "AZURE_STORAGE_IDENTITY_CLIENT_ID should be present in authEnv" )
623
+ },
624
+ },
577
625
{
578
626
name : "invalid getLatestAccountKey value" ,
579
627
testFunc : func (t * testing.T ) {
0 commit comments