Skip to content

Commit 1bbb74d

Browse files
authored
[Batch] Fix error when setting null values in job CommonEnvironmentSettings property (#26692)
* Add Batch keys and node passwords to sanitizers * [Batch] Fix null CommonEnvironmentSettings values Setting null values inside nested objects such as CommonEnvironmentSettings throw an 'Object reference not set to an instance of an object' error. Allow nulls to pass through to the Batch service so that objects which support them work properly, and those that don't throw a more useful error message from the service itself. * Remove primary & secondary from JSON sanitizers
1 parent 48ef9be commit 1bbb74d

File tree

37 files changed

+7822
-6350
lines changed

37 files changed

+7822
-6350
lines changed

src/Batch/Batch.Test/ScenarioTests/BatchAccountTests.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ function Test-BatchAccountEndToEnd
7676
# Regenerate the primary key
7777
$updatedKey = New-AzBatchAccountKey -Name $accountName -ResourceGroupName $resourceGroup -KeyType Primary
7878
Assert-NotNull $updatedKey.PrimaryAccountKey
79-
Assert-AreNotEqual $accountWithKeys.PrimaryAccountKey $updatedKey.PrimaryAccountKey
80-
Assert-AreEqual $accountWithKeys.SecondaryAccountKey $updatedKey.SecondaryAccountKey
79+
Assert-NotNull $updatedKey.SecondaryAccountKey
8180
}
8281
finally
8382
{

src/Batch/Batch.Test/ScenarioTests/JobTests.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ function Test-JobCRUD
2626

2727
try
2828
{
29-
# Create 2 jobs
3029
$poolInfo1 = New-Object Microsoft.Azure.Commands.Batch.Models.PSPoolInformation
3130
$poolInfo1.PoolId = "testPool"
32-
New-AzBatchJob -Id $jobId1 -PoolInformation $poolInfo1 -BatchContext $context
31+
$envSettings = @{
32+
"ThisIsAString" = "Hello world";
33+
# Make sure CommonEnvironmentSettings allows null values
34+
"ThisIsNull" = $null
35+
}
36+
New-AzBatchJob -Id $jobId1 -PoolInformation $poolInfo1 -CommonEnvironmentSettings $envSettings -BatchContext $context
3337

3438
$poolInfo2 = New-Object Microsoft.Azure.Commands.Batch.Models.PSPoolInformation
3539
$poolInfo2.PoolId = "testPool2"

src/Batch/Batch.Test/SessionRecords/Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchAccountTests/TestBatchAccountEndToEnd.json

Lines changed: 361 additions & 298 deletions
Large diffs are not rendered by default.

src/Batch/Batch.Test/SessionRecords/Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchAccountTests/TestCreateNewBatchAccountWithNoPublicIp.json

Lines changed: 422 additions & 350 deletions
Large diffs are not rendered by default.

src/Batch/Batch.Test/SessionRecords/Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchAccountTests/TestCreateNewBatchAccountWithSystemIdentity.json

Lines changed: 179 additions & 146 deletions
Large diffs are not rendered by default.

src/Batch/Batch.Test/SessionRecords/Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchAccountTests/TestGetBatchSupportedImages.json

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

src/Batch/Batch.Test/SessionRecords/Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchApplicationPackageTests/TestCreatePoolWithApplicationPackage.json

Lines changed: 116 additions & 95 deletions
Large diffs are not rendered by default.

src/Batch/Batch.Test/SessionRecords/Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchApplicationPackageTests/TestUpdateApplicationPackage.json

Lines changed: 155 additions & 125 deletions
Large diffs are not rendered by default.

src/Batch/Batch.Test/SessionRecords/Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchApplicationPackageTests/TestUpdatePoolWithApplicationPackage.json

Lines changed: 146 additions & 125 deletions
Large diffs are not rendered by default.

src/Batch/Batch.Test/SessionRecords/Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchApplicationPackageTests/TestUploadApplicationPackage.json

Lines changed: 98 additions & 77 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)