Skip to content

Commit

Permalink
Merge branch 'comp-md-dynamodb-2587' of github.com:robertojrojas/comp…
Browse files Browse the repository at this point in the history
…onents-contrib into comp-md-dynamodb-2587
  • Loading branch information
robertojrojas committed Jul 11, 2023
2 parents 665c9fc + bae2ad5 commit c12bc7a
Show file tree
Hide file tree
Showing 79 changed files with 1,472 additions and 278 deletions.
28 changes: 28 additions & 0 deletions .build-tools/pkg/metadataschema/builtin-authentication-profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,34 @@ import (
// ParseBuiltinAuthenticationProfile returns an AuthenticationProfile(s) from a given BuiltinAuthenticationProfile.
func ParseBuiltinAuthenticationProfile(bi BuiltinAuthenticationProfile) ([]AuthenticationProfile, error) {
switch bi.Name {
case "aws":
return []AuthenticationProfile{
{
Title: "AWS: Access Key ID and Secret Access Key",
Description: "Authenticate using an Access Key ID and Secret Access Key included in the metadata",
Metadata: []Metadata{
{
Name: "accessKey",
Required: true,
Sensitive: true,
Description: "AWS access key associated with an IAM account",
Example: `"AKIAIOSFODNN7EXAMPLE"`,
},
{
Name: "secretKey",
Required: true,
Sensitive: true,
Description: "The secret key associated with the access key",
Example: `"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"`,
},
},
},
{
Title: "AWS: Credentials from Environment Variables",
Description: "Use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from the environment",
Metadata: []Metadata{},
},
}, nil
case "azuread":
azureEnvironmentMetadata := Metadata{
Name: "azureEnvironment",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// ------------------------------------------------------------------------
// Copyright 2021 The Dapr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------

param postgresServerName string
param sdkAuthSpId string
param sdkAuthSpName string
param rgLocation string = resourceGroup().location
param confTestTags object = {}
param postgresqlVersion string = '14'
param tenantId string = subscription().tenantId

resource postgresServer 'Microsoft.DBforPostgreSQL/flexibleServers@2023-03-01-preview' = {
name: postgresServerName
location: rgLocation
tags: confTestTags
sku: {
name: 'Standard_B1ms'
tier: 'Burstable'
}
properties: {
storage: {
storageSizeGB: 32
autoGrow: 'Disabled'
}
authConfig: {
activeDirectoryAuth: 'Enabled'
passwordAuth: 'Disabled'
tenantId: tenantId
}
network: {}
version: postgresqlVersion
}

resource daprTestDB 'databases@2023-03-01-preview' = {
name: 'dapr_test'
properties: {
charset: 'UTF8'
collation: 'en_US.utf8'
}
}

resource fwRules 'firewallRules@2023-03-01-preview' = {
name: 'allowall'
properties: {
startIpAddress: '0.0.0.0'
endIpAddress: '255.255.255.255'
}
}

resource azureAdAdmin 'administrators@2023-03-01-preview' = {
name: sdkAuthSpId
properties: {
principalType: 'ServicePrincipal'
principalName: sdkAuthSpName
tenantId: tenantId
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
param sqlServerName string
param rgLocation string = resourceGroup().location
param confTestTags object = {}
@secure()
param sqlServerAdminPassword string

var sqlServerAdminName = '${sqlServerName}-admin'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,31 @@ param storageName string
param rgLocation string = resourceGroup().location
param confTestTags object = {}

resource storageAccount 'Microsoft.Storage/storageAccounts@2021-02-01' = {
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
name: storageName
sku: {
name: 'Standard_RAGRS'
}
kind: 'StorageV2'
location: rgLocation
tags: confTestTags
}

resource blobServices 'Microsoft.Storage/storageAccounts/blobServices@2021-02-01' = {
parent: storageAccount
name: 'default'
properties: {
deleteRetentionPolicy: {
enabled: true
days: 1
resource blobServices 'blobServices@2022-09-01' = {
name: 'default'
properties: {
deleteRetentionPolicy: {
enabled: true
days: 1
}
}
}
}

resource tableServices 'Microsoft.Storage/storageAccounts/tableServices@2021-09-01' = {
parent: storageAccount
name: 'default'
properties: {}
}
resource tableServices 'tableServices@2022-09-01' = {
name: 'default'
properties: {}

resource certificationTable 'Microsoft.Storage/storageAccounts/tableServices/tables@2021-09-01' = {
name: 'certificationTable'
parent: tableServices
properties: {}
resource certificationTable 'tables@2022-09-01' = {
name: 'certificationTable'
}
}
}
29 changes: 28 additions & 1 deletion .github/infrastructure/conformance/azure/conf-test-azure.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,20 @@ param adminId string

@minLength(36)
@maxLength(36)
@description('Provide the objectId of the Service Principal using secret auth with get access to secrets in Azure Key Vault.')
@description('Provide the objectId of the Service Principal using secret auth with get access to secrets in Azure Key Vault and access Azure PostgreSQL')
param sdkAuthSpId string

@description('Provide the name of the Service Principal using secret auth with get access to secrets in Azure Key Vault and access Azure PostgreSQL')
param sdkAuthSpName string

@minLength(36)
@maxLength(36)
@description('Provide the objectId of the Service Principal using cert auth with get and list access to all assets in Azure Key Vault.')
param certAuthSpId string

@minLength(16)
@description('Provide the SQL server admin password of at least 16 characters.')
@secure()
param sqlServerAdminPassword string

var confTestRgName = '${toLower(namePrefix)}-conf-test-rg'
Expand All @@ -54,6 +58,7 @@ var iotHubName = '${toLower(namePrefix)}-conf-test-iothub'
var keyVaultName = '${toLower(namePrefix)}-conf-test-kv'
var serviceBusName = '${toLower(namePrefix)}-conf-test-servicebus'
var sqlServerName = '${toLower(namePrefix)}-conf-test-sql'
var postgresServerName = '${toLower(namePrefix)}-conf-test-pg'
var storageName = '${toLower(namePrefix)}ctstorage'

resource confTestRg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
Expand All @@ -72,6 +77,7 @@ module cosmosDb 'conf-test-azure-cosmosdb.bicep' = {
params: {
confTestTags: confTestTags
cosmosDbName: cosmosDbName
rgLocation: rgLocation
}
}

Expand All @@ -81,6 +87,7 @@ module cosmosDbTable 'conf-test-azure-cosmosdb-table.bicep' = {
params: {
confTestTags: confTestTags
cosmosDbTableAPIName: cosmosDbTableAPIName
rgLocation: rgLocation
}
}

Expand All @@ -90,6 +97,7 @@ module eventGridTopic 'conf-test-azure-eventgrid.bicep' = {
params: {
confTestTags: confTestTags
eventGridTopicName: eventGridTopicName
rgLocation: rgLocation
}
}

Expand All @@ -99,6 +107,7 @@ module eventHubsNamespace 'conf-test-azure-eventhubs.bicep' = {
params: {
confTestTags: confTestTags
eventHubsNamespaceName: eventHubsNamespaceName
rgLocation: rgLocation
}
}

Expand All @@ -108,6 +117,7 @@ module iotHub 'conf-test-azure-iothub.bicep' = {
params: {
confTestTags: confTestTags
iotHubName: iotHubName
rgLocation: rgLocation
}
}

Expand All @@ -120,6 +130,7 @@ module keyVault 'conf-test-azure-keyvault.bicep' = {
certAuthSpId: certAuthSpId
keyVaultName: keyVaultName
sdkAuthSpId: sdkAuthSpId
rgLocation: rgLocation
}
}

Expand All @@ -129,6 +140,7 @@ module serviceBus 'conf-test-azure-servicebus.bicep' = {
params: {
confTestTags: confTestTags
serviceBusName: serviceBusName
rgLocation: rgLocation
}
}

Expand All @@ -139,6 +151,7 @@ module sqlServer 'conf-test-azure-sqlserver.bicep' = {
confTestTags: confTestTags
sqlServerName: sqlServerName
sqlServerAdminPassword: sqlServerAdminPassword
rgLocation: rgLocation
}
}

Expand All @@ -148,6 +161,19 @@ module storage 'conf-test-azure-storage.bicep' = {
params: {
confTestTags: confTestTags
storageName: storageName
rgLocation: rgLocation
}
}

module postgres 'conf-test-azure-postgres.bicep' = {
name: postgresServerName
scope: resourceGroup(confTestRg.name)
params: {
confTestTags: confTestTags
postgresServerName: postgresServerName
sdkAuthSpId: sdkAuthSpId
sdkAuthSpName: sdkAuthSpName
rgLocation: rgLocation
}
}

Expand Down Expand Up @@ -176,4 +202,5 @@ output keyVaultName string = keyVault.name
output serviceBusName string = serviceBus.name
output sqlServerName string = sqlServer.name
output sqlServerAdminName string = sqlServer.outputs.sqlServerAdminName
output postgresServerName string = postgres.name
output storageName string = storage.name
28 changes: 25 additions & 3 deletions .github/infrastructure/conformance/azure/setup-azure-conf-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ SQL_SERVER_NAME_VAR_NAME="AzureSqlServerName"
SQL_SERVER_DB_NAME_VAR_NAME="AzureSqlServerDbName"
SQL_SERVER_CONNECTION_STRING_VAR_NAME="AzureSqlServerConnectionString"

AZURE_DB_POSTGRES_CONNSTRING_VAR_NAME="AzureDBPostgresConnectionString"

STORAGE_ACCESS_KEY_VAR_NAME="AzureBlobStorageAccessKey"
STORAGE_ACCOUNT_VAR_NAME="AzureBlobStorageAccount"
STORAGE_CONTAINER_VAR_NAME="AzureBlobStorageContainer"
Expand Down Expand Up @@ -269,15 +271,15 @@ if [[ -n ${CREDENTIALS_PATH} ]]; then
fi
SDK_AUTH_SP_NAME="$(az ad sp show --id "${SDK_AUTH_SP_APPID}" --query "appDisplayName" --output tsv)"
SDK_AUTH_SP_ID="$(az ad sp show --id "${SDK_AUTH_SP_APPID}" --query "id" --output tsv)"
echo "Using Service Principal from ${CREDENTIALS_PATH} for SDK Auth: ${SDK_AUTH_SP_NAME}"
echo "Using Service Principal from ${CREDENTIALS_PATH} for SDK Auth: ${SDK_AUTH_SP_NAME} (ID: ${SDK_AUTH_SP_ID})"
else
SDK_AUTH_SP_NAME="${PREFIX}-conf-test-runner-sp"
SDK_AUTH_SP_INFO="$(az ad sp create-for-rbac --name "${SDK_AUTH_SP_NAME}" --sdk-auth --years 1)"
SDK_AUTH_SP_APPID="$(echo "${SDK_AUTH_SP_INFO}" | jq -r '.clientId')"
SDK_AUTH_SP_CLIENT_SECRET="$(echo "${SDK_AUTH_SP_INFO}" | jq -r '.clientSecret')"
SDK_AUTH_SP_ID="$(az ad sp list --display-name "${SDK_AUTH_SP_NAME}" --query "[].id" --output tsv)"
echo "${SDK_AUTH_SP_INFO}"
echo "Created Service Principal for SDK Auth: ${SDK_AUTH_SP_NAME}"
echo "Created Service Principal for SDK Auth: ${SDK_AUTH_SP_NAME} (ID: ${SDK_AUTH_SP_ID})"
AZURE_CREDENTIALS_FILENAME="${OUTPUT_PATH}/AZURE_CREDENTIALS"
echo "${SDK_AUTH_SP_INFO}" > "${AZURE_CREDENTIALS_FILENAME}"
fi
Expand All @@ -292,7 +294,17 @@ echo "Building conf-test-azure.bicep to ${ARM_TEMPLATE_FILE} ..."
az bicep build --file conf-test-azure.bicep --outfile "${ARM_TEMPLATE_FILE}"

echo "Creating azure deployment ${DEPLOY_NAME} in ${DEPLOY_LOCATION} and resource prefix ${PREFIX}-* ..."
az deployment sub create --name "${DEPLOY_NAME}" --location "${DEPLOY_LOCATION}" --template-file "${ARM_TEMPLATE_FILE}" -p namePrefix="${PREFIX}" -p adminId="${ADMIN_ID}" -p certAuthSpId="${CERT_AUTH_SP_ID}" -p sdkAuthSpId="${SDK_AUTH_SP_ID}" -p rgLocation="${DEPLOY_LOCATION}" -p sqlServerAdminPassword="${SQL_SERVER_ADMIN_PASSWORD}"
az deployment sub create \
--name "${DEPLOY_NAME}" \
--location "${DEPLOY_LOCATION}" \
--template-file "${ARM_TEMPLATE_FILE}" \
-p namePrefix="${PREFIX}" \
-p adminId="${ADMIN_ID}" \
-p certAuthSpId="${CERT_AUTH_SP_ID}" \
-p sdkAuthSpId="${SDK_AUTH_SP_ID}" \
-p sdkAuthSpName="${SDK_AUTH_SP_NAME}" \
-p rgLocation="${DEPLOY_LOCATION}" \
-p sqlServerAdminPassword="${SQL_SERVER_ADMIN_PASSWORD}"

echo "Sleeping for 5s to allow created ARM deployment info to propagate to query endpoints ..."
sleep 5
Expand Down Expand Up @@ -546,6 +558,7 @@ az keyvault secret set --name "${KEYVAULT_SERVICE_PRINCIPAL_CLIENT_ID_VAR_NAME}"
KEYVAULT_SERVICE_PRINCIPAL_CLIENT_SECRET=${AKV_SPAUTH_SP_CLIENT_SECRET}
echo export ${KEYVAULT_SERVICE_PRINCIPAL_CLIENT_SECRET_VAR_NAME}=\"${KEYVAULT_SERVICE_PRINCIPAL_CLIENT_SECRET}\" >> "${ENV_CONFIG_FILENAME}"
az keyvault secret set --name "${KEYVAULT_SERVICE_PRINCIPAL_CLIENT_SECRET_VAR_NAME}" --vault-name "${KEYVAULT_NAME}" --value "${KEYVAULT_SERVICE_PRINCIPAL_CLIENT_SECRET}"

# ------------------------------------
# Populate Blob Storage test settings
# ------------------------------------
Expand Down Expand Up @@ -671,6 +684,15 @@ SQL_SERVER_CONNECTION_STRING="Server=${SQL_SERVER_NAME}.database.windows.net;por
echo export ${SQL_SERVER_CONNECTION_STRING_VAR_NAME}=\"${SQL_SERVER_CONNECTION_STRING}\" >> "${ENV_CONFIG_FILENAME}"
az keyvault secret set --name "${SQL_SERVER_CONNECTION_STRING_VAR_NAME}" --vault-name "${KEYVAULT_NAME}" --value "${SQL_SERVER_CONNECTION_STRING}"

# ----------------------------------
# Populate Azure Database for PostgreSQL test settings
# ----------------------------------
echo "Configuring Azure Database for PostgreSQL test settings ..."

AZURE_DB_POSTGRES_CONNSTRING="host=${PREFIX}-conf-test-pg.postgres.database.azure.com user=${SDK_AUTH_SP_NAME} port=5432 connect_timeout=30 database=dapr_test"
echo export ${AZURE_DB_POSTGRES_CONNSTRING_VAR_NAME}=\"${AZURE_DB_POSTGRES_CONNSTRING}\" >> "${ENV_CONFIG_FILENAME}"
az keyvault secret set --name "${AZURE_DB_POSTGRES_CONNSTRING_VAR_NAME}" --vault-name "${KEYVAULT_NAME}" --value "${AZURE_DB_POSTGRES_CONNSTRING}"

# ----------------------------------
# Populate Event Hubs test settings
# ----------------------------------
Expand Down
24 changes: 22 additions & 2 deletions .github/scripts/test-info.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,11 @@ const components = {
'internal/component/sql',
],
},
'state.etcd': {
'state.etcd.v1': {
conformance: true,
conformanceSetup: 'docker-compose.sh etcd',
},
'state.etcd.v2': {
conformance: true,
conformanceSetup: 'docker-compose.sh etcd',
},
Expand Down Expand Up @@ -578,15 +582,31 @@ const components = {
conformanceSetup: 'docker-compose.sh oracledatabase',
},
'state.postgresql': {
conformance: true,
certification: true,
sourcePkg: [
'state/postgresql',
'internal/component/postgresql',
'internal/component/sql',
],
},
'state.postgresql.docker': {
conformance: true,
conformanceSetup: 'docker-compose.sh postgresql',
sourcePkg: [
'state/postgresql',
'internal/component/postgresql',
'internal/component/sql',
],
},
'state.postgresql.azure': {
conformance: true,
requiredSecrets: ['AzureDBPostgresConnectionString'],
sourcePkg: [
'state/postgresql',
'internal/component/postgresql',
'internal/component/sql',
],
},
'state.redis': {
certification: true,
sourcePkg: ['state/redis', 'internal/component/redis'],
Expand Down
Loading

0 comments on commit c12bc7a

Please sign in to comment.