Skip to content

Commit 47da5b5

Browse files
authored
Merge pull request Azure#10159 from solankisamir/sasolank/apimfixes
Added support for ApiVersion set in Set-AzApiManagementApi
2 parents fedd2c4 + dc42a19 commit 47da5b5

37 files changed

+4241
-3325
lines changed

src/ApiManagement/ApiManagement.ServiceManagement.Test/ScenarioTests/ApiManagementTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,18 @@ public void BackendServiceFabricCrudTest()
242242
RunPowerShellTest("BackendServiceFabric-CrudTest");
243243
}
244244

245+
[Fact]
246+
[Trait(Category.AcceptanceType, Category.CheckIn)]
247+
public void ApiVersionSetImportCrudTest()
248+
{
249+
RunPowerShellTest("ApiVersionSet-ImportCrudTest");
250+
}
251+
245252
[Fact]
246253
[Trait(Category.AcceptanceType, Category.CheckIn)]
247254
public void ApiVersionSetCrudTest()
248255
{
249-
RunPowerShellTest("ApiVersionSet-CrudTest");
256+
RunPowerShellTest("ApiVersionSet-SetCrudTest");
250257
}
251258

252259
[Fact]

src/ApiManagement/ApiManagement.ServiceManagement.Test/ScenarioTests/ApiManagementTests.ps1

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2964,9 +2964,88 @@ function BackendServiceFabric-CrudTest {
29642964

29652965
<#
29662966
.SYNOPSIS
2967-
Tests CRUD operations of APIVersion set.
2967+
Tests CRUD operations of APIVersion set when performing Set ON Api
29682968
#>
2969-
function ApiVersionSet-CrudTest {
2969+
function ApiVersionSet-SetCrudTest {
2970+
Param($resourceGroupName, $serviceName)
2971+
2972+
$context = New-AzApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName
2973+
2974+
# get all apis
2975+
$apiversionsets = Get-AzApiManagementApiVersionSet -Context $context
2976+
# there should be no API Version sets initially
2977+
Assert-AreEqual 0 $apiversionsets.Count
2978+
2979+
# new api details
2980+
$swaggerPath = Join-Path (Join-Path "$TestOutputRoot" "Resources") "SwaggerPetStoreV2.json"
2981+
$path1 = "swaggerapifromFile"
2982+
$swaggerApiId1 = getAssetName
2983+
$newApiVersionSetId = getAssetName
2984+
try {
2985+
$newVersionSetName = getAssetName
2986+
$queryName = getAssetName
2987+
$description = getAssetName
2988+
2989+
$newApiVersionSet = New-AzApiManagementApiVersionSet -Context $context -ApiVersionSetId $newApiVersionSetId -Name $newVersionSetName -Scheme Query `
2990+
-QueryName $queryName -Description $description
2991+
2992+
Assert-AreEqual $newApiVersionSetId $newApiVersionSet.ApiVersionSetId
2993+
Assert-AreEqual $newVersionSetName $newApiVersionSet.DisplayName
2994+
Assert-AreEqual $description $newApiVersionSet.Description
2995+
Assert-AreEqual Query $newApiVersionSet.VersioningScheme
2996+
Assert-AreEqual $queryName $newApiVersionSet.VersionQueryName
2997+
Assert-Null $newApiVersionSet.VersionHeaderName
2998+
2999+
# update the versioning scheme to be header based
3000+
$versionHeaderName = getAssetName
3001+
$newApiVersionSet = Set-AzApiManagementApiVersionSet -Context $context -ApiVersionSetId $newApiVersionSetId `
3002+
-Scheme Header -HeaderName $versionHeaderName -PassThru
3003+
3004+
Assert-AreEqual $newApiVersionSetId $newApiVersionSet.ApiVersionSetId
3005+
Assert-AreEqual $newVersionSetName $newApiVersionSet.DisplayName
3006+
Assert-AreEqual $description $newApiVersionSet.Description
3007+
Assert-AreEqual Header $newApiVersionSet.VersioningScheme
3008+
Assert-AreEqual $versionHeaderName $newApiVersionSet.VersionHeaderName
3009+
3010+
# get the api version set using id
3011+
$newApiVersionSet = Get-AzApiManagementApiVersionSet -Context $context -ApiVersionSetId $newApiVersionSetId
3012+
Assert-AreEqual $newApiVersionSetId $newApiVersionSet.ApiVersionSetId
3013+
Assert-AreEqual $newVersionSetName $newApiVersionSet.DisplayName
3014+
Assert-AreEqual $description $newApiVersionSet.Description
3015+
Assert-AreEqual Header $newApiVersionSet.VersioningScheme
3016+
Assert-AreEqual $versionHeaderName $newApiVersionSet.VersionHeaderName
3017+
3018+
# import api from file
3019+
$api = Import-AzApiManagementApi -Context $context -ApiId $swaggerApiId1 -SpecificationPath $swaggerPath -SpecificationFormat Swagger -Path $path1
3020+
Assert-AreEqual $swaggerApiId1 $api.ApiId
3021+
Assert-AreEqual $path1 $api.Path
3022+
3023+
# now add the api to the version set
3024+
$api.ApiVersionSetId = $newApiVersionSet.Id
3025+
$api.APIVersion = "v1"
3026+
$api.ApiVersionSetDescription = $newApiVersionSet.Description
3027+
$updatedApi = Set-AzApiManagementApi -InputObject $api -PassThru
3028+
Assert-NotNull $updatedApi
3029+
Assert-AreEqual $newApiVersionSet.Id $updatedApi.ApiVersionSetId
3030+
Assert-AreEqual $newApiVersionSet.Description $updatedApi.ApiVersionSetDescription
3031+
Assert-AreEqual "v1" $updatedApi.ApiVersion
3032+
}
3033+
finally {
3034+
# remove created api
3035+
$removed = Remove-AzApiManagementApi -Context $context -ApiId $swaggerApiId1 -PassThru
3036+
Assert-True { $removed }
3037+
3038+
# remove created api version set
3039+
$removed = Remove-AzApiManagementApiVersionSet -Context $context -ApiVersionSetId $newApiVersionSetId -PassThru
3040+
Assert-True { $removed }
3041+
}
3042+
}
3043+
3044+
<#
3045+
.SYNOPSIS
3046+
Tests CRUD operations of APIVersion set when Importing an API
3047+
#>
3048+
function ApiVersionSet-ImportCrudTest {
29703049
Param($resourceGroupName, $serviceName)
29713050

29723051
$context = New-AzApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName

src/ApiManagement/ApiManagement.ServiceManagement.Test/SessionRecords/Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Test.ScenarioTests.ApiManagementTests/ApiCloneCrudTest.json

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

0 commit comments

Comments
 (0)