@@ -550,7 +550,23 @@ func TestGetAuthEnv(t *testing.T) {
550550 name : "valid request" ,
551551 testFunc : func (t * testing.T ) {
552552 d := NewFakeDriver ()
553- attrib := make (map [string ]string )
553+ attrib := map [string ]string {
554+ subscriptionIDField : "subID" ,
555+ resourceGroupField : "rg" ,
556+ storageAccountField : "accountname" ,
557+ storageAccountNameField : "accountname" ,
558+ secretNameField : "secretName" ,
559+ secretNamespaceField : "sNS" ,
560+ containerNameField : "containername" ,
561+ mountWithWITokenField : "false" ,
562+ pvcNamespaceKey : "pvcNSKey" ,
563+ getAccountKeyFromSecretField : "false" ,
564+ storageAuthTypeField : "key" ,
565+ msiEndpointField : "msiEndpoint" ,
566+ getLatestAccountKeyField : "true" ,
567+ tenantIDField : "tenantID" ,
568+ serviceAccountTokenField : "serviceAccountToken" ,
569+ }
554570 secret := make (map [string ]string )
555571 volumeID := "rg#f5713de20cde511e8ba4900#pvc-fuse-dynamic-17e43f84-f474-11e8-acd0-000d3a00df41"
556572 d .cloud = & storage.AccountRepo {}
@@ -580,23 +596,29 @@ func TestGetAuthEnv(t *testing.T) {
580596 }
581597 secret := make (map [string ]string )
582598 volumeID := "rg#f5713de20cde511e8ba4900#pvc-fuse-dynamic-17e43f84-f474-11e8-acd0-000d3a00df41"
583- d .cloud = & storage.AccountRepo {}
584- ctrl := gomock .NewController (t )
585- defer ctrl .Finish ()
586- mockStorageAccountsClient := mock_accountclient .NewMockInterface (ctrl )
587- d .cloud .ComputeClientFactory = mock_azclient .NewMockClientFactory (ctrl )
588- d .cloud .ComputeClientFactory .(* mock_azclient.MockClientFactory ).EXPECT ().GetAccountClient ().Return (mockStorageAccountsClient ).AnyTimes ()
589- s := "unit-test"
590- accountkey := armstorage.AccountKey {Value : & s }
591- list := []* armstorage.AccountKey {& accountkey }
592- mockStorageAccountsClient .EXPECT ().ListKeys (gomock .Any (), gomock .Any (), gomock .Any ()).Return (list , nil ).AnyTimes ()
593599 _ , _ , _ , _ , _ , err := d .GetAuthEnv (context .TODO (), volumeID , "" , attrib , secret )
594600 expectedErr := fmt .Errorf ("invalid getlatestaccountkey: %s in volume context" , "invalid" )
595601 if ! reflect .DeepEqual (err , expectedErr ) {
596602 t .Errorf ("actualErr: (%v), expectedErr: (%v)" , err , expectedErr )
597603 }
598604 },
599605 },
606+ {
607+ name : "invalid mountWithWIToken value" ,
608+ testFunc : func (t * testing.T ) {
609+ d := NewFakeDriver ()
610+ attrib := map [string ]string {
611+ mountWithWITokenField : "invalid" ,
612+ }
613+ secret := make (map [string ]string )
614+ volumeID := "rg#f5713de20cde511e8ba4900#pvc-fuse-dynamic-17e43f84-f474-11e8-acd0-000d3a00df41"
615+ _ , _ , _ , _ , _ , err := d .GetAuthEnv (context .TODO (), volumeID , "" , attrib , secret )
616+ expectedErr := fmt .Errorf ("invalid %s: %s in volume context" , mountWithWITokenField , "invalid" )
617+ if ! reflect .DeepEqual (err , expectedErr ) {
618+ t .Errorf ("actualErr: (%v), expectedErr: (%v)" , err , expectedErr )
619+ }
620+ },
621+ },
600622 {
601623 name : "secret not empty" ,
602624 testFunc : func (t * testing.T ) {
0 commit comments