-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cosmos DB Output Binding - Authentication tests (#1373)
* Adds CosmosDB Binding authentication tests Signed-off-by: GitHub <noreply@github.com> Signed-off-by: Bernd Verst <4535280+berndverst@users.noreply.github.com> * Enable Cosmos DB Binding Conformance test Signed-off-by: GitHub <noreply@github.com> Signed-off-by: Bernd Verst <4535280+berndverst@users.noreply.github.com> * Initial cosmosdb binding certification plan WIP Signed-off-by: GitHub <noreply@github.com> Signed-off-by: Bernd Verst <4535280+berndverst@users.noreply.github.com> * Go mod tidy Signed-off-by: GitHub <noreply@github.com> Signed-off-by: Bernd Verst <4535280+berndverst@users.noreply.github.com> * Update library and go mod tidy Signed-off-by: GitHub <noreply@github.com> Signed-off-by: Bernd Verst <4535280+berndverst@users.noreply.github.com> * make modtidy-all Signed-off-by: Bernd Verst <4535280+berndverst@users.noreply.github.com> * CosmosDB Binding test plan details Signed-off-by: Bernd Verst <4535280+berndverst@users.noreply.github.com>
- Loading branch information
1 parent
72bae26
commit 9dbdaee
Showing
23 changed files
with
2,143 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Azure CosmosDB Binding certification testing | ||
|
||
This project aims to test the Azure CosmosDB binding component under various conditions. | ||
|
||
## Test plan | ||
|
||
### Authentication tests | ||
|
||
* Authenticate with Azure Active Directory using Service Principal Client Secret | ||
* Authenticate with Master Key | ||
|
||
### Other tests | ||
- TODO: Verify data sent to output binding is written to Cosmos DB | ||
- TODO: Expected failure for invalid partition key specified (Component Metadata Partition Key does not match Cosmos DB container) | ||
- TODO: Expected failure for partition key missing from document | ||
- TODO: Expected failure for `id` missing from document | ||
- TODO: Graceful handling of connection resets / interruption (client connection only, not during Invoke/Create operation itself) | ||
|
||
### Running the tests | ||
|
||
This must be run in the GitHub Actions Workflow configured for test infrastructure setup. | ||
|
||
If you have access to an Azure subscription you can run this locally on Mac or Linux after running `setup-azure-conf-test.sh` in `.github/infrastructure/conformance/azure` and then sourcing the generated bash rc file. |
30 changes: 30 additions & 0 deletions
30
tests/certification/bindings/azure/cosmosdb/components/masterkey/cosmosdb.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: dapr.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: azure-cosmosdb-binding | ||
namespace: default | ||
spec: | ||
type: bindings.azure.cosmosdb | ||
version: v1 | ||
metadata: | ||
- name: url | ||
secretKeyRef: | ||
name: AzureCosmosDBUrl | ||
key: AzureCosmosDBUrl | ||
- name: database | ||
secretKeyRef: | ||
name: AzureCosmosDB | ||
key: AzureCosmosDB | ||
- name: collection | ||
secretKeyRef: | ||
name: AzureCosmosDBCollection | ||
key: AzureCosmosDBCollection | ||
- name: partitionKey | ||
value: partitionKey | ||
- name: masterKey | ||
secretKeyRef: | ||
name: AzureCosmosDBMasterKey | ||
key: AzureCosmosDBMasterKey | ||
|
||
auth: | ||
secretStore: envvar-secret-store |
9 changes: 9 additions & 0 deletions
9
tests/certification/bindings/azure/cosmosdb/components/masterkey/localsecrets.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
38 changes: 38 additions & 0 deletions
38
tests/certification/bindings/azure/cosmosdb/components/serviceprincipal/cosmosdb.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apiVersion: dapr.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: azure-cosmosdb-binding | ||
namespace: default | ||
spec: | ||
type: bindings.azure.cosmosdb | ||
version: v1 | ||
metadata: | ||
- name: url | ||
secretKeyRef: | ||
name: AzureCosmosDBUrl | ||
key: AzureCosmosDBUrl | ||
- name: database | ||
secretKeyRef: | ||
name: AzureCosmosDB | ||
key: AzureCosmosDB | ||
- name: collection | ||
secretKeyRef: | ||
name: AzureCosmosDBCollection | ||
key: AzureCosmosDBCollection | ||
- name: partitionKey | ||
value: partitionKey | ||
- name: azureTenantId | ||
secretKeyRef: | ||
name: AzureCertificationTenantId | ||
key: AzureCertificationTenantId | ||
- name: azureClientId | ||
secretKeyRef: | ||
name: AzureCertificationServicePrincipalClientId | ||
key: AzureCertificationServicePrincipalClientId | ||
- name: azureClientSecret | ||
secretKeyRef: | ||
name: AzureCertificationServicePrincipalClientSecret | ||
key: AzureCertificationServicePrincipalClientSecret | ||
|
||
auth: | ||
secretStore: envvar-secret-store |
9 changes: 9 additions & 0 deletions
9
tests/certification/bindings/azure/cosmosdb/components/serviceprincipal/localsecrets.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: dapr.io/v1alpha1 | ||
kind: Configuration | ||
metadata: | ||
name: keyvaultconfig | ||
spec: | ||
features: |
82 changes: 82 additions & 0 deletions
82
tests/certification/bindings/azure/cosmosdb/cosmosdb_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// ------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation and Dapr Contributors. | ||
// Licensed under the MIT License. | ||
// ------------------------------------------------------------ | ||
|
||
package keyvault_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/dapr/components-contrib/bindings" | ||
cosmosdbbinding "github.com/dapr/components-contrib/bindings/azure/cosmosdb" | ||
"github.com/dapr/components-contrib/secretstores" | ||
secretstore_env "github.com/dapr/components-contrib/secretstores/local/env" | ||
bindings_loader "github.com/dapr/dapr/pkg/components/bindings" | ||
secretstores_loader "github.com/dapr/dapr/pkg/components/secretstores" | ||
"github.com/dapr/dapr/pkg/runtime" | ||
dapr_testing "github.com/dapr/dapr/pkg/testing" | ||
"github.com/dapr/kit/logger" | ||
|
||
"github.com/dapr/components-contrib/tests/certification/embedded" | ||
"github.com/dapr/components-contrib/tests/certification/flow" | ||
"github.com/dapr/components-contrib/tests/certification/flow/sidecar" | ||
) | ||
|
||
const ( | ||
sidecarName = "cosmosdb-sidecar" | ||
) | ||
|
||
func TestKeyVault(t *testing.T) { | ||
ports, err := dapr_testing.GetFreePorts(2) | ||
assert.NoError(t, err) | ||
|
||
currentGrpcPort := ports[0] | ||
currentHttpPort := ports[1] | ||
|
||
log := logger.NewLogger("dapr.components") | ||
|
||
flow.New(t, "cosmosdb binding authentication using service principal"). | ||
Step(sidecar.Run(sidecarName, | ||
embedded.WithoutApp(), | ||
embedded.WithComponentsPath("./components/serviceprincipal"), | ||
embedded.WithDaprGRPCPort(currentGrpcPort), | ||
embedded.WithDaprHTTPPort(currentHttpPort), | ||
runtime.WithSecretStores( | ||
secretstores_loader.New("local.env", func() secretstores.SecretStore { | ||
return secretstore_env.NewEnvSecretStore(log) | ||
}), | ||
), | ||
runtime.WithOutputBindings( | ||
bindings_loader.NewOutput("azure.cosmosdb", func() bindings.OutputBinding { | ||
return cosmosdbbinding.NewCosmosDB(log) | ||
}), | ||
))). | ||
Run() | ||
|
||
ports, err = dapr_testing.GetFreePorts(2) | ||
assert.NoError(t, err) | ||
|
||
currentGrpcPort = ports[0] | ||
currentHttpPort = ports[1] | ||
|
||
flow.New(t, "cosmosdb binding authentication using master key"). | ||
Step(sidecar.Run(sidecarName, | ||
embedded.WithoutApp(), | ||
embedded.WithComponentsPath("./components/masterkey"), | ||
embedded.WithDaprGRPCPort(currentGrpcPort), | ||
embedded.WithDaprHTTPPort(currentHttpPort), | ||
runtime.WithSecretStores( | ||
secretstores_loader.New("local.env", func() secretstores.SecretStore { | ||
return secretstore_env.NewEnvSecretStore(log) | ||
}), | ||
), | ||
runtime.WithOutputBindings( | ||
bindings_loader.NewOutput("azure.cosmosdb", func() bindings.OutputBinding { | ||
return cosmosdbbinding.NewCosmosDB(log) | ||
}), | ||
))). | ||
Run() | ||
} |
Oops, something went wrong.