Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ACL copying with Blob #2525

Merged
merged 10 commits into from
Mar 12, 2024
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
adreed-msft committed Mar 11, 2024
commit 80fe144373ff1c2703f0a262aac77d7337d3e406
189 changes: 173 additions & 16 deletions e2etest/zt_basic_cli_ps_auth_test.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,179 @@
// Copyright © Microsoft <wastore@microsoft.com>
// // Copyright © Microsoft <wastore@microsoft.com>
// //
// // Permission is hereby granted, free of charge, to any person obtaining a copy
// // of this software and associated documentation files (the "Software"), to deal
// // in the Software without restriction, including without limitation the rights
// // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// // copies of the Software, and to permit persons to whom the Software is
// // furnished to do so, subject to the following conditions:
// //
// // The above copyright notice and this permission notice shall be included in
// // all copies or substantial portions of the Software.
// //
// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// // THE SOFTWARE.
package e2etest

//
//import (
// "fmt"
// "os"
// "os/exec"
// "testing"
//
// "github.com/Azure/azure-storage-azcopy/v10/common"
//)
//
//// Purpose: Tests AZCLI and powershell auth tests
//
//func TestBasic_AzCLIAuth(t *testing.T) {
// RunScenarios(t, eOperation.Copy(), eTestFromTo.Other(common.EFromTo.BlobBlob()), eValidate.Auto(), oAuthOnly, oAuthOnly, params{ // Pass flag values that the test requires. The params struct is a superset of Copy and Sync params
// recursive: true,
// }, &hooks{
// beforeTestRun: func(h hookHelper) {
// tenId, appId, clientSecret := GlobalInputManager{}.GetServicePrincipalAuth()
// args := []string{
// "login",
// "--service-principal",
// "-u=" + appId,
// "-p=" + clientSecret,
// }
// if tenId != "" {
// args = append(args, "--tenant="+tenId)
// }
//
// out, err := exec.Command("az", args...).Output()
// if err != nil {
// e := err.(*exec.ExitError)
// t.Logf(string(e.Stderr))
// t.Logf(string(out))
// t.Logf("Failed to login with AzCLI " + err.Error())
// t.FailNow()
// }
// os.Setenv("AZCOPY_AUTO_LOGIN_TYPE", "AZCLI")
// },
// }, testFiles{
// defaultSize: "1K",
// shouldTransfer: []interface{}{
// "wantedfile",
// folder("sub/subsub"),
// "sub/subsub/filea",
// "sub/subsub/filec",
// },
// }, EAccountType.Standard(), EAccountType.Standard(), "")
//}
//
//func TestBasic_AzCLIAuthLowerCase(t *testing.T) {
// RunScenarios(t, eOperation.Copy(), eTestFromTo.Other(common.EFromTo.BlobBlob()), eValidate.Auto(), oAuthOnly, oAuthOnly, params{ // Pass flag values that the test requires. The params struct is a superset of Copy and Sync params
// recursive: true,
// }, &hooks{
// beforeTestRun: func(h hookHelper) {
// tenId, appId, clientSecret := GlobalInputManager{}.GetServicePrincipalAuth()
// args := []string{
// "login",
// "--service-principal",
// "-u=" + appId,
// "-p=" + clientSecret,
// }
// if tenId != "" {
// args = append(args, "--tenant="+tenId)
// }
//
// out, err := exec.Command("az", args...).Output()
// if err != nil {
// e := err.(*exec.ExitError)
// t.Logf(string(e.Stderr))
// t.Logf(string(out))
// t.Logf("Failed to login with AzCLI " + err.Error())
// t.FailNow()
// }
// os.Setenv("AZCOPY_AUTO_LOGIN_TYPE", "azcli")
// },
// }, testFiles{
// defaultSize: "1K",
// shouldTransfer: []interface{}{
// "wantedfile",
// folder("sub/subsub"),
// "sub/subsub/filea",
// "sub/subsub/filec",
// },
// }, EAccountType.Standard(), EAccountType.Standard(), "")
//}
//
//func TestBasic_PSAuth(t *testing.T) {
// RunScenarios(t, eOperation.Copy(), eTestFromTo.Other(common.EFromTo.BlobBlob()), eValidate.Auto(), oAuthOnly, oAuthOnly, params{ // Pass flag values that the test requires. The params struct is a superset of Copy and Sync params
// recursive: true,
// }, &hooks{
// beforeTestRun: func(h hookHelper) {
// tenId, appId, clientSecret := GlobalInputManager{}.GetServicePrincipalAuth()
// cmd := `$secret = ConvertTo-SecureString -String %s -AsPlainText -Force;
// $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList %s, $secret;
// Connect-AzAccount -ServicePrincipal -Credential $cred`
// if tenId != "" {
// cmd += " -Tenant " + tenId
// }
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// script := fmt.Sprintf(cmd, clientSecret, appId)
// out, err := exec.Command("pwsh", "-Command", script).Output()
// if err != nil {
// e := err.(*exec.ExitError)
// t.Logf(string(e.Stderr))
// t.Logf(string(out))
// t.Logf("Failed to login with Powershell " + err.Error())
// t.FailNow()
// }
// os.Setenv("AZCOPY_AUTO_LOGIN_TYPE", "PSCRED")
// },
// }, testFiles{
// defaultSize: "1K",
// shouldTransfer: []interface{}{
// "wantedfile",
// folder("sub/subsub"),
// "sub/subsub/filea",
// "sub/subsub/filec",
// },
// }, EAccountType.Standard(), EAccountType.Standard(), "")
//}
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//func TestBasic_PSAuthCamelCase(t *testing.T) {
// RunScenarios(t, eOperation.Copy(), eTestFromTo.Other(common.EFromTo.BlobBlob()), eValidate.Auto(), oAuthOnly, oAuthOnly, params{ // Pass flag values that the test requires. The params struct is a superset of Copy and Sync params
// recursive: true,
// }, &hooks{
// beforeTestRun: func(h hookHelper) {
// tenId, appId, clientSecret := GlobalInputManager{}.GetServicePrincipalAuth()
// cmd := `$secret = ConvertTo-SecureString -String %s -AsPlainText -Force;
// $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList %s, $secret;
// Connect-AzAccount -ServicePrincipal -Credential $cred`
// if tenId != "" {
// cmd += " -Tenant " + tenId
// }
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// script := fmt.Sprintf(cmd, clientSecret, appId)
// out, err := exec.Command("pwsh", "-Command", script).Output()
// if err != nil {
// e := err.(*exec.ExitError)
// t.Logf(string(e.Stderr))
// t.Logf(string(out))
// t.Logf("Failed to login with Powershell " + err.Error())
// t.FailNow()
// }
// os.Setenv("AZCOPY_AUTO_LOGIN_TYPE", "PsCred")
// },
// }, testFiles{
// defaultSize: "1K",
// shouldTransfer: []interface{}{
// "wantedfile",
// folder("sub/subsub"),
// "sub/subsub/filea",
// "sub/subsub/filec",
// },
// }, EAccountType.Standard(), EAccountType.Standard(), "")
//}

package e2etest

22 changes: 16 additions & 6 deletions e2etest/zt_basic_copy_sync_remove_test.go
Original file line number Diff line number Diff line change
@@ -368,7 +368,7 @@ func TestBasic_CopyRemoveFolderHNS(t *testing.T) {
desc: "AllRemove",
useAllTos: true,
froms: []common.Location{
common.ELocation.Blob(), // blobfs isn't technically supported; todo: support it properly rather than jank through Blob
common.ELocation.BlobFS(),
},
tos: []common.Location{
common.ELocation.Unknown(),
@@ -419,8 +419,19 @@ func TestBasic_CopyRemoveFolderHNS(t *testing.T) {
}

func TestBasic_CopyRemoveContainer(t *testing.T) {
bfsRemove := TestFromTo{
desc: "AllRemove",
useAllTos: true,
froms: []common.Location{
common.ELocation.Blob(), // If you have a container-level SAS and a HNS account, you can't delete the container. HNS should not be included here.
common.ELocation.File(),
},
tos: []common.Location{
common.ELocation.Unknown(),
},
}

RunScenarios(t, eOperation.Remove(), eTestFromTo.AllRemove(), eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
RunScenarios(t, eOperation.Remove(), bfsRemove, eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
recursive: true,
relativeSourcePath: "",
}, nil, testFiles{
@@ -438,7 +449,7 @@ func TestBasic_CopyRemoveContainerHNS(t *testing.T) {
desc: "AllRemove",
useAllTos: true,
froms: []common.Location{
common.ELocation.Blob(), // blobfs isn't technically supported; todo: support it properly rather than jank through Blob
common.ELocation.BlobFS(),
},
tos: []common.Location{
common.ELocation.Unknown(),
@@ -472,7 +483,6 @@ func TestBasic_CopyRemoveContainerHNS(t *testing.T) {
_, err = fsURL.GetAccessControl(ctx, nil)
a.Assert(err, notEquals(), nil)
a.Assert(datalakeerror.HasCode(err, "FilesystemNotFound"), equals(), true)

},
},
testFiles{
@@ -869,7 +879,7 @@ func TestBasic_OverwriteHNSDirWithChildren(t *testing.T) {
RunScenarios(
t,
eOperation.Copy(),
eTestFromTo.Other(common.EFromTo.LocalBlobFS()),
eTestFromTo.Other(common.EFromTo.BlobFSBlobFS()),
eValidate.Auto(),
anonymousAuthOnly,
anonymousAuthOnly,
@@ -1066,7 +1076,7 @@ func TestBasic_SyncRemoveFoldersHNS(t *testing.T) {
RunScenarios(
t,
eOperation.Sync(),
eTestFromTo.Other(common.EFromTo.BlobBlob()),
eTestFromTo.Other(common.EFromTo.BlobFSBlobFS()),
eValidate.Auto(),
anonymousAuthOnly,
anonymousAuthOnly,