Skip to content

Commit

Permalink
FT WI
Browse files Browse the repository at this point in the history
Signed-off-by: willdavsmith <[email protected]>
  • Loading branch information
willdavsmith committed Aug 8, 2024
1 parent efb4494 commit 9197ee1
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
)

func Test_PersistentVolume(t *testing.T) {
t.Skip()
template := "testdata/corerp-resources-volume-azure-keyvault.bicep"
name := "corerp-resources-volume-azure-keyvault"
appNamespace := "corerp-resources-volume-azure-keyvault-app"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import (
"github.com/radius-project/radius/test/validation"
)

// Test_Storage tests if a container can be created and then deleted by the magpiego with the workload identity.
// Test_Storage tests if a container on an Azure Storage Account can be created and then deleted by the magpiego with the workload identity.
func Test_Storage(t *testing.T) {
t.Skip()
template := "testdata/corerp-resources-container-workload.bicep"
name := "corerp-resources-container-workload"
appNamespace := "azstorage-workload-app"
Expand Down
111 changes: 56 additions & 55 deletions test/magpiego/bindings/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"

// "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
"github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential"
)

Expand All @@ -27,60 +28,60 @@ func StorageBinding(envParams map[string]string) BindingStatus {
return BindingStatus{false, "CONNECTION_STORAGE_ACCOUNTNAME is required"}
}

url := "https://" + storageAccountName + ".blob.core.windows.net/"

clientID := os.Getenv("AZURE_CLIENT_ID")
tenantID := os.Getenv("AZURE_TENANT_ID")
tokenFilePath := os.Getenv("AZURE_FEDERATED_TOKEN_FILE")
authorityHost := os.Getenv("AZURE_AUTHORITY_HOST")

if clientID == "" {
log.Println("AZURE_CLIENT_ID is required")
return BindingStatus{false, "AZURE_CLIENT_ID is required"}
}
if tenantID == "" {
log.Println("AZURE_TENANT_ID is required")
return BindingStatus{false, "AZURE_TENANT_ID is required"}
}
if tokenFilePath == "" {
log.Println("AZURE_FEDERATED_TOKEN_FILE is required")
return BindingStatus{false, "AZURE_FEDERATED_TOKEN_FILE is required"}
}
if authorityHost == "" {
log.Println("AZURE_AUTHORITY_HOST is required")
return BindingStatus{false, "AZURE_AUTHORITY_HOST is required"}
}

cred, err := newClientAssertionCredential(tenantID, clientID, authorityHost, tokenFilePath)
if err != nil {
log.Println("Failed to create credential")
return BindingStatus{false, "Failed to create credential"}
}

client, err := azblob.NewClient(url, cred, nil)
if err != nil {
log.Println("Failed to create client")
return BindingStatus{false, "Failed to create client"}
}

containerName := fmt.Sprintf("magpiego-%s", randomString())
log.Println("Container Name: " + containerName)

// Create a container
resp, err := client.CreateContainer(context.TODO(), containerName, nil)
if err != nil {
log.Printf("Failed to create container: %s\n", err.Error())
return BindingStatus{false, "Failed to create container"}
}
log.Printf("Successfully created a blob container %q. Response: %s\n", containerName, string(*resp.RequestID))

// Delete the container
delResp, err := client.DeleteContainer(context.TODO(), containerName, nil)
if err != nil {
log.Printf("Failed to mark container for deletion: %s\n", err.Error())
return BindingStatus{false, "Failed to mark container for deletion"}
}
log.Printf("Successfully marked the container for deletion %q. Response: %s\n", containerName, string(*delResp.RequestID))
// url := "https://" + storageAccountName + ".blob.core.windows.net/"

// clientID := os.Getenv("AZURE_CLIENT_ID")
// tenantID := os.Getenv("AZURE_TENANT_ID")
// tokenFilePath := os.Getenv("AZURE_FEDERATED_TOKEN_FILE")
// authorityHost := os.Getenv("AZURE_AUTHORITY_HOST")

// if clientID == "" {
// log.Println("AZURE_CLIENT_ID is required")
// return BindingStatus{false, "AZURE_CLIENT_ID is required"}
// }
// if tenantID == "" {
// log.Println("AZURE_TENANT_ID is required")
// return BindingStatus{false, "AZURE_TENANT_ID is required"}
// }
// if tokenFilePath == "" {
// log.Println("AZURE_FEDERATED_TOKEN_FILE is required")
// return BindingStatus{false, "AZURE_FEDERATED_TOKEN_FILE is required"}
// }
// if authorityHost == "" {
// log.Println("AZURE_AUTHORITY_HOST is required")
// return BindingStatus{false, "AZURE_AUTHORITY_HOST is required"}
// }

// cred, err := newClientAssertionCredential(tenantID, clientID, authorityHost, tokenFilePath)
// if err != nil {
// log.Println("Failed to create credential")
// return BindingStatus{false, "Failed to create credential"}
// }

// client, err := azblob.NewClient(url, cred, nil)
// if err != nil {
// log.Println("Failed to create client")
// return BindingStatus{false, "Failed to create client"}
// }

// containerName := fmt.Sprintf("magpiego-%s", randomString())
// log.Println("Container Name: " + containerName)

// // Create a container
// resp, err := client.CreateContainer(context.TODO(), containerName, nil)
// if err != nil {
// log.Printf("Failed to create container: %s\n", err.Error())
// return BindingStatus{false, "Failed to create container"}
// }
// log.Printf("Successfully created a blob container %q. Response: %s\n", containerName, string(*resp.RequestID))

// // Delete the container
// delResp, err := client.DeleteContainer(context.TODO(), containerName, nil)
// if err != nil {
// log.Printf("Failed to mark container for deletion: %s\n", err.Error())
// return BindingStatus{false, "Failed to mark container for deletion"}
// }
// log.Printf("Successfully marked the container for deletion %q. Response: %s\n", containerName, string(*delResp.RequestID))

return BindingStatus{true, "Created a container and marked it for deletion successfully"}
}
Expand Down
2 changes: 1 addition & 1 deletion test/magpiego/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/radius-project/radius/test/magpiego

go 1.22
go 1.22.0

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0
Expand Down

0 comments on commit 9197ee1

Please sign in to comment.