@@ -1538,10 +1538,8 @@ func TestCopyVolume(t *testing.T) {
1538
1538
VolumeContentSource : & volumecontensource ,
1539
1539
}
1540
1540
1541
- ctx := context .Background ()
1542
-
1543
1541
expectedErr := status .Errorf (codes .InvalidArgument , "copy volume from volumeSnapshot is not supported" )
1544
- err := d .copyVolume (ctx , req , "" , "" , "core.windows.net" )
1542
+ err := d .copyVolume (req , "" , nil , "" , "core.windows.net" )
1545
1543
if ! reflect .DeepEqual (err , expectedErr ) {
1546
1544
t .Errorf ("Unexpected error: %v" , err )
1547
1545
}
@@ -1570,10 +1568,8 @@ func TestCopyVolume(t *testing.T) {
1570
1568
VolumeContentSource : & volumecontensource ,
1571
1569
}
1572
1570
1573
- ctx := context .Background ()
1574
-
1575
1571
expectedErr := status .Errorf (codes .NotFound , "error parsing volume id: \" unit-test\" , should at least contain two #" )
1576
- err := d .copyVolume (ctx , req , "" , "dstContainer" , "core.windows.net" )
1572
+ err := d .copyVolume (req , "" , nil , "dstContainer" , "core.windows.net" )
1577
1573
if ! reflect .DeepEqual (err , expectedErr ) {
1578
1574
t .Errorf ("Unexpected error: %v" , err )
1579
1575
}
@@ -1602,10 +1598,8 @@ func TestCopyVolume(t *testing.T) {
1602
1598
VolumeContentSource : & volumecontensource ,
1603
1599
}
1604
1600
1605
- ctx := context .Background ()
1606
-
1607
1601
expectedErr := fmt .Errorf ("srcContainerName() or dstContainerName(dstContainer) is empty" )
1608
- err := d .copyVolume (ctx , req , "" , "dstContainer" , "core.windows.net" )
1602
+ err := d .copyVolume (req , "" , nil , "dstContainer" , "core.windows.net" )
1609
1603
if ! reflect .DeepEqual (err , expectedErr ) {
1610
1604
t .Errorf ("Unexpected error: %v" , err )
1611
1605
}
@@ -1634,42 +1628,8 @@ func TestCopyVolume(t *testing.T) {
1634
1628
VolumeContentSource : & volumecontensource ,
1635
1629
}
1636
1630
1637
- ctx := context .Background ()
1638
-
1639
1631
expectedErr := fmt .Errorf ("srcContainerName(fileshare) or dstContainerName() is empty" )
1640
- err := d .copyVolume (ctx , req , "" , "" , "core.windows.net" )
1641
- if ! reflect .DeepEqual (err , expectedErr ) {
1642
- t .Errorf ("Unexpected error: %v" , err )
1643
- }
1644
- },
1645
- },
1646
- {
1647
- name : "AADClientSecret shouldn't be nil or useManagedIdentityExtension must be set to true when accountSASToken is empty" ,
1648
- testFunc : func (t * testing.T ) {
1649
- d := NewFakeDriver ()
1650
- mp := map [string ]string {}
1651
-
1652
- volumeSource := & csi.VolumeContentSource_VolumeSource {
1653
- VolumeId : "vol_1#f5713de20cde511e8ba4900#fileshare#" ,
1654
- }
1655
- volumeContentSourceVolumeSource := & csi.VolumeContentSource_Volume {
1656
- Volume : volumeSource ,
1657
- }
1658
- volumecontensource := csi.VolumeContentSource {
1659
- Type : volumeContentSourceVolumeSource ,
1660
- }
1661
-
1662
- req := & csi.CreateVolumeRequest {
1663
- Name : "unit-test" ,
1664
- VolumeCapabilities : stdVolumeCapabilities ,
1665
- Parameters : mp ,
1666
- VolumeContentSource : & volumecontensource ,
1667
- }
1668
-
1669
- ctx := context .Background ()
1670
-
1671
- expectedErr := fmt .Errorf ("service principle or managed identity are both not set" )
1672
- err := d .copyVolume (ctx , req , "" , "dstContainer" , "core.windows.net" )
1632
+ err := d .copyVolume (req , "" , nil , "" , "core.windows.net" )
1673
1633
if ! reflect .DeepEqual (err , expectedErr ) {
1674
1634
t .Errorf ("Unexpected error: %v" , err )
1675
1635
}
@@ -1710,10 +1670,8 @@ func TestCopyVolume(t *testing.T) {
1710
1670
1711
1671
d .azcopy .ExecCmd = m
1712
1672
1713
- ctx := context .Background ()
1714
-
1715
1673
var expectedErr error
1716
- err := d .copyVolume (ctx , req , "sastoken" , "dstContainer" , "core.windows.net" )
1674
+ err := d .copyVolume (req , "sastoken" , nil , "dstContainer" , "core.windows.net" )
1717
1675
if ! reflect .DeepEqual (err , expectedErr ) {
1718
1676
t .Errorf ("Unexpected error: %v" , err )
1719
1677
}
@@ -1755,10 +1713,8 @@ func TestCopyVolume(t *testing.T) {
1755
1713
1756
1714
d .azcopy .ExecCmd = m
1757
1715
1758
- ctx := context .Background ()
1759
-
1760
1716
var expectedErr error
1761
- err := d .copyVolume (ctx , req , "sastoken" , "dstContainer" , "core.windows.net" )
1717
+ err := d .copyVolume (req , "sastoken" , nil , "dstContainer" , "core.windows.net" )
1762
1718
if ! reflect .DeepEqual (err , expectedErr ) {
1763
1719
t .Errorf ("Unexpected error: %v" , err )
1764
1720
}
@@ -1989,7 +1945,7 @@ func TestAuthorizeAzcopyWithIdentity(t *testing.T) {
1989
1945
}
1990
1946
}
1991
1947
1992
- func TestGetSASToken (t * testing.T ) {
1948
+ func TestGetAzcopyAuth (t * testing.T ) {
1993
1949
testCases := []struct {
1994
1950
name string
1995
1951
testFunc func (t * testing.T )
@@ -2008,7 +1964,7 @@ func TestGetSASToken(t *testing.T) {
2008
1964
ctx := context .Background ()
2009
1965
expectedAccountSASToken := ""
2010
1966
expectedErr := fmt .Errorf ("could not find accountkey or azurestorageaccountkey field in secrets" )
2011
- accountSASToken , err := d .getSASToken (ctx , "accountName" , "" , "core.windows.net" , & azure.AccountOptions {}, secrets , "secretsName" , "secretsNamespace" )
1967
+ accountSASToken , _ , err := d .getAzcopyAuth (ctx , "accountName" , "" , "core.windows.net" , & azure.AccountOptions {}, secrets , "secretsName" , "secretsNamespace" )
2012
1968
if ! reflect .DeepEqual (err , expectedErr ) || ! reflect .DeepEqual (accountSASToken , expectedAccountSASToken ) {
2013
1969
t .Errorf ("Unexpected accountSASToken: %s, Unexpected error: %v" , accountSASToken , err )
2014
1970
}
@@ -2031,7 +1987,7 @@ func TestGetSASToken(t *testing.T) {
2031
1987
defaultSecretAccountName : "accountName" ,
2032
1988
defaultSecretAccountKey : "YWNjb3VudGtleQo=" ,
2033
1989
}
2034
- accountSASToken , err := d .getSASToken (context .Background (), "accountName" , "" , "core.windows.net" , & azure.AccountOptions {}, secrets , "secretsName" , "secretsNamespace" )
1990
+ accountSASToken , _ , err := d .getAzcopyAuth (context .Background (), "accountName" , "" , "core.windows.net" , & azure.AccountOptions {}, secrets , "secretsName" , "secretsNamespace" )
2035
1991
if ! reflect .DeepEqual (err , nil ) || ! strings .Contains (accountSASToken , "?se=" ) {
2036
1992
t .Errorf ("Unexpected accountSASToken: %s, Unexpected error: %v" , accountSASToken , err )
2037
1993
}
@@ -2057,7 +2013,7 @@ func TestGetSASToken(t *testing.T) {
2057
2013
2058
2014
expectedAccountSASToken := ""
2059
2015
expectedErr := status .Errorf (codes .Internal , fmt .Sprintf ("failed to generate sas token in creating new shared key credential, accountName: %s, err: %s" , "accountName" , "decode account key: illegal base64 data at input byte 8" ))
2060
- accountSASToken , err := d .getSASToken (context .Background (), "accountName" , "" , "core.windows.net" , & azure.AccountOptions {}, secrets , "secretsName" , "secretsNamespace" )
2016
+ accountSASToken , _ , err := d .getAzcopyAuth (context .Background (), "accountName" , "" , "core.windows.net" , & azure.AccountOptions {}, secrets , "secretsName" , "secretsNamespace" )
2061
2017
if ! reflect .DeepEqual (err , expectedErr ) || ! reflect .DeepEqual (accountSASToken , expectedAccountSASToken ) {
2062
2018
t .Errorf ("Unexpected accountSASToken: %s, Unexpected error: %v" , accountSASToken , err )
2063
2019
}
@@ -2078,7 +2034,7 @@ func TestGetSASToken(t *testing.T) {
2078
2034
ctx := context .Background ()
2079
2035
expectedAccountSASToken := ""
2080
2036
expectedErr := status .Errorf (codes .Internal , fmt .Sprintf ("failed to generate sas token in creating new shared key credential, accountName: %s, err: %s" , "accountName" , "decode account key: illegal base64 data at input byte 8" ))
2081
- accountSASToken , err := d .getSASToken (ctx , "accountName" , "" , "core.windows.net" , & azure.AccountOptions {}, secrets , "secretsName" , "secretsNamespace" )
2037
+ accountSASToken , _ , err := d .getAzcopyAuth (ctx , "accountName" , "" , "core.windows.net" , & azure.AccountOptions {}, secrets , "secretsName" , "secretsNamespace" )
2082
2038
if ! reflect .DeepEqual (err , expectedErr ) || ! reflect .DeepEqual (accountSASToken , expectedAccountSASToken ) {
2083
2039
t .Errorf ("Unexpected accountSASToken: %s, Unexpected error: %v" , accountSASToken , err )
2084
2040
}
0 commit comments