Skip to content

Commit

Permalink
Update cert tests for v2
Browse files Browse the repository at this point in the history
Signed-off-by: ItalyPaleAle <[email protected]>
  • Loading branch information
ItalyPaleAle committed Oct 31, 2023
1 parent 6adedf5 commit 0122e7f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 8 deletions.
39 changes: 31 additions & 8 deletions tests/certification/state/azure/blobstorage/blobstorage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import (
"strconv"
"testing"

blob "github.com/dapr/components-contrib/state/azure/blobstorage"
component_v1 "github.com/dapr/components-contrib/state/azure/blobstorage/v1"
component_v2 "github.com/dapr/components-contrib/state/azure/blobstorage/v2"
"github.com/dapr/components-contrib/tests/certification/embedded"
"github.com/dapr/components-contrib/tests/certification/flow"
"github.com/dapr/dapr/pkg/components"
"github.com/dapr/go-sdk/client"
"github.com/dapr/kit/logger"

Expand Down Expand Up @@ -78,14 +80,27 @@ func TestAzureBlobStorage(t *testing.T) {
return nil
}

flow.New(t, "Test basic operations, save/get/delete using existing container").
flow.New(t, "v1 - Test basic operations, save/get/delete using existing container").
// Run the Dapr sidecar with azure blob storage.
Step(sidecar.Run(sidecarNamePrefix,
append(componentRuntimeOptions(),
embedded.WithoutApp(),
embedded.WithDaprGRPCPort(strconv.Itoa(currentGrpcPort)),
embedded.WithDaprHTTPPort(strconv.Itoa(currentHTTPPort)),
embedded.WithComponentsPath("./components/basictest"),
embedded.WithResourcesPath("./components/basictest-v1"),
)...,
)).
Step("Run basic test with existing container", basicTest("statestore-basic")).
Run()

flow.New(t, "v2 - Test basic operations, save/get/delete using existing container").
// Run the Dapr sidecar with azure blob storage.
Step(sidecar.Run(sidecarNamePrefix,
append(componentRuntimeOptions(),
embedded.WithoutApp(),
embedded.WithDaprGRPCPort(strconv.Itoa(currentGrpcPort)),
embedded.WithDaprHTTPPort(strconv.Itoa(currentHTTPPort)),
embedded.WithResourcesPath("./components/basictest-v2"),
)...,
)).
Step("Run basic test with existing container", basicTest("statestore-basic")).
Expand All @@ -98,11 +113,11 @@ func TestAzureBlobStorage(t *testing.T) {
embedded.WithoutApp(),
embedded.WithDaprGRPCPort(strconv.Itoa(currentGrpcPort)),
embedded.WithDaprHTTPPort(strconv.Itoa(currentHTTPPort)),
embedded.WithComponentsPath("./components/nonexistingcontainertest"),
embedded.WithResourcesPath("./components/nonexistingcontainertest"),
)...,
)).
Step("Run basic test with new table", basicTest("statestore-newcontainer")).
Step("Delete the New Table", deleteContainer).
Step("Run basic test with new container", basicTest("statestore-newcontainer")).
Step("Delete the new container", deleteContainer).
Run()

flow.New(t, "Test for authentication using Azure Auth layer").
Expand All @@ -112,7 +127,7 @@ func TestAzureBlobStorage(t *testing.T) {
embedded.WithoutApp(),
embedded.WithDaprGRPCPort(strconv.Itoa(currentGrpcPort)),
embedded.WithDaprHTTPPort(strconv.Itoa(currentHTTPPort)),
embedded.WithComponentsPath("./components/aadtest"),
embedded.WithResourcesPath("./components/aadtest"),
)...,
)).
Step("Run AAD test", basicTest("statestore-aad")).
Expand All @@ -124,7 +139,15 @@ func componentRuntimeOptions() []embedded.Option {

stateRegistry := state_loader.NewRegistry()
stateRegistry.Logger = log
stateRegistry.RegisterComponent(blob.NewAzureBlobStorageStore, "azure.blobstorage")
stateRegistry.RegisterComponentWithVersions("azure.blobstorage", components.Versioning{
Preferred: components.VersionConstructor{
Version: "v2", Constructor: component_v1.NewAzureBlobStorageStore,
},
Deprecated: []components.VersionConstructor{
{Version: "v1", Constructor: component_v2.NewAzureBlobStorageStore},
},
Default: "v1",
})

secretstoreRegistry := secretstores_loader.NewRegistry()
secretstoreRegistry.Logger = log
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore-basic
spec:
type: state.azure.blobstorage
version: v1
metadata:
- name: accountName
secretKeyRef:
name: AzureBlobStorageAccount
key: AzureBlobStorageAccount
- name: accountKey
secretKeyRef:
name: AzureBlobStorageAccessKey
key: AzureBlobStorageAccessKey
- name: containerName
secretKeyRef:
name: AzureBlobStorageContainer
key: AzureBlobStorageContainer
auth:
secretstore: envvar-secret-store
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: envvar-secret-store
namespace: default
spec:
type: secretstores.local.env
version: v1
metadata:

0 comments on commit 0122e7f

Please sign in to comment.