@@ -2964,9 +2964,88 @@ function BackendServiceFabric-CrudTest {
2964
2964
2965
2965
<#
2966
2966
. SYNOPSIS
2967
- Tests CRUD operations of APIVersion set.
2967
+ Tests CRUD operations of APIVersion set when performing Set ON Api
2968
2968
#>
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 {
2970
3049
Param ($resourceGroupName , $serviceName )
2971
3050
2972
3051
$context = New-AzApiManagementContext - ResourceGroupName $resourceGroupName - ServiceName $serviceName
0 commit comments