From 16e490769f7e2cb5d631d82d2d695a5dbd041332 Mon Sep 17 00:00:00 2001 From: Sindhu Nagesh Date: Tue, 23 Mar 2021 11:19:30 -0700 Subject: [PATCH] fix(e2e): Fix some environment varialbe names for consistency (#1849) --- ...n.AzureSecurityCenterForIoTLogAnalytics.cs | 2 +- e2e/test/config/Configuration.IoTHub.cs | 2 +- .../DeviceClientX509AuthenticationE2ETests.cs | 24 +++++++------- .../E2ETestsSetup/e2eTestsSetup.ps1 | 33 +++++++++---------- vsts/vsts.yaml | 8 ++--- 5 files changed, 34 insertions(+), 35 deletions(-) diff --git a/e2e/test/config/Configuration.AzureSecurityCenterForIoTLogAnalytics.cs b/e2e/test/config/Configuration.AzureSecurityCenterForIoTLogAnalytics.cs index f45e25a3c0..43b6bb67ae 100644 --- a/e2e/test/config/Configuration.AzureSecurityCenterForIoTLogAnalytics.cs +++ b/e2e/test/config/Configuration.AzureSecurityCenterForIoTLogAnalytics.cs @@ -8,7 +8,7 @@ public static partial class Configuration public static class AzureSecurityCenterForIoTLogAnalytics { // The Azure Active directory tenant (The subscription tenant) - public static string AadTenant => GetValue("LA_AAD_TENANT"); + public static string AadTenant => GetValue("MSFT_TENANT_ID"); // The Azure active directory used for authentication against log analytics public static string AadAppId => GetValue("LA_AAD_APP_ID"); diff --git a/e2e/test/config/Configuration.IoTHub.cs b/e2e/test/config/Configuration.IoTHub.cs index ffc96e3129..7d7e28ed87 100644 --- a/e2e/test/config/Configuration.IoTHub.cs +++ b/e2e/test/config/Configuration.IoTHub.cs @@ -11,7 +11,7 @@ public static partial class Configuration { public static partial class IoTHub { - public static string ConnectionString => GetValue("IOTHUB_CONN_STRING_CSHARP"); + public static string ConnectionString => GetValue("IOTHUB_CONNECTION_STRING"); public static string X509ChainDeviceName => GetValue("IOTHUB_X509_CHAIN_DEVICE_NAME"); public static X509Certificate2 GetCertificateWithPrivateKey() diff --git a/e2e/test/iothub/DeviceClientX509AuthenticationE2ETests.cs b/e2e/test/iothub/DeviceClientX509AuthenticationE2ETests.cs index 95a2f10b5d..96c04852bf 100644 --- a/e2e/test/iothub/DeviceClientX509AuthenticationE2ETests.cs +++ b/e2e/test/iothub/DeviceClientX509AuthenticationE2ETests.cs @@ -35,76 +35,76 @@ public DeviceClientX509AuthenticationE2ETests() [TestCategory("LongRunning")] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Amqp() { - await X509InvalidDeviceIdOpenAsyncTest(Client.TransportType.Amqp).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTest(DeviceTransportType.Amqp).ConfigureAwait(false); } [LoggedTestMethod] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Amqp_Tcp() { - await X509InvalidDeviceIdOpenAsyncTest(Client.TransportType.Amqp_Tcp_Only).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTest(DeviceTransportType.Amqp_Tcp_Only).ConfigureAwait(false); } [LoggedTestMethod] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Amqp_WebSocket() { - await X509InvalidDeviceIdOpenAsyncTest(Client.TransportType.Amqp_WebSocket_Only).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTest(DeviceTransportType.Amqp_WebSocket_Only).ConfigureAwait(false); } [LoggedTestMethod] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Mqtt() { - await X509InvalidDeviceIdOpenAsyncTest(Client.TransportType.Mqtt).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTest(DeviceTransportType.Mqtt).ConfigureAwait(false); } [LoggedTestMethod] [TestCategory("LongRunning")] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Mqtt_Tcp() { - await X509InvalidDeviceIdOpenAsyncTest(Client.TransportType.Mqtt_Tcp_Only).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTest(DeviceTransportType.Mqtt_Tcp_Only).ConfigureAwait(false); } [LoggedTestMethod] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Mqtt_WebSocket() { - await X509InvalidDeviceIdOpenAsyncTest(Client.TransportType.Mqtt_WebSocket_Only).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTest(DeviceTransportType.Mqtt_WebSocket_Only).ConfigureAwait(false); } [LoggedTestMethod] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Twice_Amqp() { - await X509InvalidDeviceIdOpenAsyncTwiceTest(Client.TransportType.Amqp).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTwiceTest(DeviceTransportType.Amqp).ConfigureAwait(false); } [LoggedTestMethod] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Twice_Amqp_TCP() { - await X509InvalidDeviceIdOpenAsyncTwiceTest(Client.TransportType.Amqp_Tcp_Only).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTwiceTest(DeviceTransportType.Amqp_Tcp_Only).ConfigureAwait(false); } [LoggedTestMethod] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Twice_Amqp_WebSocket() { - await X509InvalidDeviceIdOpenAsyncTwiceTest(Client.TransportType.Amqp_WebSocket_Only).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTwiceTest(DeviceTransportType.Amqp_WebSocket_Only).ConfigureAwait(false); } [LoggedTestMethod] [TestCategory("LongRunning")] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Twice_Mqtt() { - await X509InvalidDeviceIdOpenAsyncTwiceTest(Client.TransportType.Mqtt).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTwiceTest(DeviceTransportType.Mqtt).ConfigureAwait(false); } [LoggedTestMethod] [TestCategory("LongRunning")] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Twice_Mqtt_Tcp() { - await X509InvalidDeviceIdOpenAsyncTwiceTest(Client.TransportType.Mqtt_Tcp_Only).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTwiceTest(DeviceTransportType.Mqtt_Tcp_Only).ConfigureAwait(false); } [LoggedTestMethod] public async Task X509_InvalidDeviceId_Throw_UnauthorizedException_Twice_Mqtt_WebSocket() { - await X509InvalidDeviceIdOpenAsyncTwiceTest(Client.TransportType.Mqtt_WebSocket_Only).ConfigureAwait(false); + await X509InvalidDeviceIdOpenAsyncTwiceTest(DeviceTransportType.Mqtt_WebSocket_Only).ConfigureAwait(false); } [LoggedTestMethod] diff --git a/e2e/test/prerequisites/E2ETestsSetup/e2eTestsSetup.ps1 b/e2e/test/prerequisites/E2ETestsSetup/e2eTestsSetup.ps1 index 1e4dedb8cc..8fdc766698 100644 --- a/e2e/test/prerequisites/E2ETestsSetup/e2eTestsSetup.ps1 +++ b/e2e/test/prerequisites/E2ETestsSetup/e2eTestsSetup.ps1 @@ -110,7 +110,7 @@ if (-not $isAdmin) ################################################################################################# $Region = $Region.Replace(' ', '') -$appRegistrationName = $ResourceGroup +$logAnalyticsAppRegnName = $ResourceGroup $uploadCertificateName = "group1-certificate" $hubUploadCertificateName = "rootCA" @@ -317,19 +317,19 @@ if ($InstallDependencies) # Configure an AAD app and create self signed certs and get the bytes to generate more content info. ################################################################################################################################################# -$appId = az ad app list --show-mine --query "[?displayName=='$appRegistrationName'].appId" --output tsv -if (-not $appId) +$logAnalyticsAppId = az ad app list --show-mine --query "[?displayName=='$logAnalyticsAppRegnName'].appId" --output tsv +if (-not $logAnalyticsAppId) { - Write-Host "`nCreating App Registration $appRegistrationName" - $appId = az ad app create --display-name $appRegistrationName --reply-urls https://api.loganalytics.io/ --available-to-other-tenants false --query 'appId' --output tsv - Write-Host "`nApplication $appRegistrationName with Id $appId was created successfully." + Write-Host "`nCreating App Registration $logAnalyticsAppRegnName" + $logAnalyticsAppId = az ad app create --display-name $logAnalyticsAppRegnName --reply-urls https://api.loganalytics.io/ --available-to-other-tenants false --query 'appId' --output tsv + Write-Host "`nApplication $logAnalyticsAppRegnName with Id $logAnalyticsAppId was created successfully." } -$spExists = az ad sp list --show-mine --query "[?appId=='$appId'].appId" --output tsv +$spExists = az ad sp list --show-mine --query "[?appId=='$logAnalyticsAppId'].appId" --output tsv if (-not $spExists) { Write-Host "`nCreating the service principal for the app registration if it does not exist" - az ad sp create --id $appId --output none + az ad sp create --id $logAnalyticsAppId --output none } ###################################################################################################### @@ -527,13 +527,13 @@ az iot dps enrollment create ` # The Service Principal takes a while to get propogated and if a different endpoint is hit before that, trying to grant a permission will fail. # Adding retries so that we can grant the permissions successfully without re-running the script. -Write-Host "`nGranting $appId Reader role assignment to the $ResourceGroup resource group." +Write-Host "`nGranting $logAnalyticsAppId Reader role assignment to the $ResourceGroup resource group." $tries = 0; while (++$tries -le 10) { try { - az role assignment create --role Reader --assignee $appId --resource-group $ResourceGroup --output none + az role assignment create --role Reader --assignee $logAnalyticsAppId --resource-group $ResourceGroup --output none if ($LastExitCode -eq 0) { @@ -556,8 +556,8 @@ while (++$tries -le 10) } Write-Host "`nCreating a self-signed certificate and placing it in $ResourceGroup" -az ad app credential reset --id $appId --create-cert --keyvault $keyVaultName --cert $ResourceGroup --output none -Write-Host "`nSuccessfully created a self signed certificate for your application $appRegistrationName in $keyVaultName key vault with cert name $ResourceGroup"; +az ad app credential reset --id $logAnalyticsAppId --create-cert --keyvault $keyVaultName --cert $ResourceGroup --output none +Write-Host "`nSuccessfully created a self signed certificate for your application $logAnalyticsAppRegnName in $keyVaultName key vault with cert name $ResourceGroup"; Write-Host "`nFetching the certificate binary" $selfSignedCerts = "$PSScriptRoot\selfSignedCerts" @@ -579,15 +579,12 @@ Remove-Item -r $selfSignedCerts Write-Host("`nWriting secrets to KeyVault $keyVaultName") az keyvault set-policy -g $ResourceGroup --name $keyVaultName --object-id $userObjectId --secret-permissions delete get list set --output none -az keyvault secret set --vault-name $keyVaultName --name "IOTHUB-CONN-STRING-CSHARP" --value $iotHubConnectionString --output none az keyvault secret set --vault-name $keyVaultName --name "IOTHUB-CONNECTION-STRING" --value $iotHubConnectionString --output none # Iot Hub Connection string Environment variable for Java az keyvault secret set --vault-name $keyVaultName --name "IOTHUB-PFX-X509-THUMBPRINT" --value $iotHubThumbprint --output none az keyvault secret set --vault-name $keyVaultName --name "IOTHUB-PROXY-SERVER-ADDRESS" --value $proxyServerAddress --output none az keyvault secret set --vault-name $keyVaultName --name "FAR-AWAY-IOTHUB-HOSTNAME" --value $farHubHostName --output none az keyvault secret set --vault-name $keyVaultName --name "DPS-IDSCOPE" --value $dpsIdScope --output none -az keyvault secret set --vault-name $keyVaultName --name "IOT-DPS-ID-SCOPE" --value $dpsIdScope --output none # DPS ID Scope Environment variable for Java az keyvault secret set --vault-name $keyVaultName --name "PROVISIONING-CONNECTION-STRING" --value $dpsConnectionString --output none -az keyvault secret set --vault-name $keyVaultName --name "IOT-DPS-CONNECTION-STRING" --value $dpsConnectionString --output none # DPS Connection string Environment variable for Java az keyvault secret set --vault-name $keyVaultName --name "CUSTOM-ALLOCATION-POLICY-WEBHOOK" --value $customAllocationPolicyWebhook --output none az keyvault secret set --vault-name $keyVaultName --name "DPS-GLOBALDEVICEENDPOINT" --value "global.azure-devices-provisioning.net" --output none az keyvault secret set --vault-name $keyVaultName --name "DPS-X509-PFX-CERTIFICATE-PASSWORD" --value $dpsX509PfxCertificatePassword --output none @@ -597,8 +594,8 @@ az keyvault secret set --vault-name $keyVaultName --name "DPS-GROUPX509-PFX-CERT az keyvault secret set --vault-name $keyVaultName --name "DPS-GROUPX509-CERTIFICATE-CHAIN" --value $dpsGroupX509CertificateChain --output none az keyvault secret set --vault-name $keyVaultName --name "STORAGE-ACCOUNT-CONNECTION-STRING" --value $storageAccountConnectionString --output none az keyvault secret set --vault-name $keyVaultName --name "LA-WORKSPACE-ID" --value $workspaceId --output none -az keyvault secret set --vault-name $keyVaultName --name "LA-AAD-TENANT" --value "72f988bf-86f1-41af-91ab-2d7cd011db47" --output none -az keyvault secret set --vault-name $keyVaultName --name "LA-AAD-APP-ID" --value $appId --output none +az keyvault secret set --vault-name $keyVaultName --name "MSFT-TENANT-ID" --value "72f988bf-86f1-41af-91ab-2d7cd011db47" --output none +az keyvault secret set --vault-name $keyVaultName --name "LA-AAD-APP-ID" --value $logAnalyticsAppId --output none az keyvault secret set --vault-name $keyVaultName --name "LA-AAD-APP-CERT-BASE64" --value $fileContentB64String --output none az keyvault secret set --vault-name $keyVaultName --name "DPS-GLOBALDEVICEENDPOINT-INVALIDCERT" --value "invalidcertgde1.westus.cloudapp.azure.com" --output none az keyvault secret set --vault-name $keyVaultName --name "PIPELINE-ENVIRONMENT" --value "prod" --output none @@ -609,6 +606,8 @@ az keyvault secret set --vault-name $keyVaultName --name "HUB-CHAIN-INTERMEDIATE az keyvault secret set --vault-name $keyVaultName --name "IOTHUB-X509-CHAIN-DEVICE-NAME" --value $iotHubCertChainDeviceCommonName --output none # Below Environment variables are only used in Java +az keyvault secret set --vault-name $keyVaultName --name "IOT-DPS-CONNECTION-STRING" --value $dpsConnectionString --output none # DPS Connection string Environment variable for Java +az keyvault secret set --vault-name $keyVaultName --name "IOT-DPS-ID-SCOPE" --value $dpsIdScope --output none # DPS ID Scope Environment variable for Java az keyvault secret set --vault-name $keyVaultName --name "FAR-AWAY-IOTHUB-CONNECTION-STRING" --value $farHubConnectionString --output none az keyvault secret set --vault-name $keyVaultName --name "IS-BASIC-TIER-HUB" --value "false" --output none diff --git a/vsts/vsts.yaml b/vsts/vsts.yaml index d4d8b1d7c6..95bbe299b2 100644 --- a/vsts/vsts.yaml +++ b/vsts/vsts.yaml @@ -61,7 +61,7 @@ jobs: - powershell: ./vsts/gatedBuild.ps1 displayName: build env: - IOTHUB_CONN_STRING_CSHARP: $(IOTHUB-CONN-STRING-CSHARP) + IOTHUB_CONNECTION_STRING: $(IOTHUB-CONNECTION-STRING) IOTHUB_PFX_X509_THUMBPRINT: $(IOTHUB-PFX-X509-THUMBPRINT) IOTHUB_X509_PFX_CERTIFICATE: $(IOTHUB-X509-PFX-CERTIFICATE) DPS_IDSCOPE: $(DPS-IDSCOPE) @@ -81,7 +81,7 @@ jobs: FAR_AWAY_IOTHUB_HOSTNAME: $(FAR-AWAY-IOTHUB-HOSTNAME) CUSTOM_ALLOCATION_POLICY_WEBHOOK: $(CUSTOM-ALLOCATION-POLICY-WEBHOOK) IOTHUB_PROXY_SERVER_ADDRESS: 127.0.0.1:8888 - LA_AAD_TENANT: $(LA-AAD-TENANT) + MSFT_TENANT_ID: $(MSFT-TENANT-ID) LA_AAD_APP_ID: $(LA-AAD-APP-ID) LA_AAD_APP_CERT_BASE64: $(LA-AAD-APP-CERT-BASE64) LA_WORKSPACE_ID: $(LA-WORKSPACE-ID) @@ -157,7 +157,7 @@ jobs: - powershell: ./vsts/gatedBuild.ps1 displayName: build env: - IOTHUB_CONN_STRING_CSHARP: $(IOTHUB-CONN-STRING-CSHARP) + IOTHUB_CONNECTION_STRING: $(IOTHUB-CONNECTION-STRING) IOTHUB_PFX_X509_THUMBPRINT: $(IOTHUB-PFX-X509-THUMBPRINT) IOTHUB_X509_PFX_CERTIFICATE: $(IOTHUB-X509-PFX-CERTIFICATE) DPS_IDSCOPE: $(DPS-IDSCOPE) @@ -177,7 +177,7 @@ jobs: FAR_AWAY_IOTHUB_HOSTNAME: $(FAR-AWAY-IOTHUB-HOSTNAME) CUSTOM_ALLOCATION_POLICY_WEBHOOK: $(CUSTOM-ALLOCATION-POLICY-WEBHOOK) IOTHUB_PROXY_SERVER_ADDRESS: 127.0.0.1:3128 - LA_AAD_TENANT: $(LA-AAD-TENANT) + MSFT_TENANT_ID: $(MSFT-TENANT-ID) LA_AAD_APP_ID: $(LA-AAD-APP-ID) LA_AAD_APP_CERT_BASE64: $(LA-AAD-APP-CERT-BASE64) LA_WORKSPACE_ID: $(LA-WORKSPACE-ID)