Skip to content

Commit

Permalink
fix(e2e): Fix some environment varialbe names for consistency (Azure#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vinagesh authored Mar 23, 2021
1 parent 371484b commit 16e4907
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/config/Configuration.IoTHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
24 changes: 12 additions & 12 deletions e2e/test/iothub/DeviceClientX509AuthenticationE2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
33 changes: 16 additions & 17 deletions e2e/test/prerequisites/E2ETestsSetup/e2eTestsSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ if (-not $isAdmin)
#################################################################################################

$Region = $Region.Replace(' ', '')
$appRegistrationName = $ResourceGroup
$logAnalyticsAppRegnName = $ResourceGroup
$uploadCertificateName = "group1-certificate"
$hubUploadCertificateName = "rootCA"

Expand Down Expand Up @@ -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
}

######################################################################################################
Expand Down Expand Up @@ -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)
{
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions vsts/vsts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 16e4907

Please sign in to comment.