@@ -1130,6 +1130,58 @@ function SubscriptionOldModel-CrudTest {
1130
1130
Assert-AreEqual $patchedSk $sub.SecondaryKey
1131
1131
Assert-AreEqual $newSubscriptionState $sub.State
1132
1132
Assert-AreEqual $patchedExpirationDate $sub.ExpirationDate
1133
+
1134
+ # Get subscriptions by product id
1135
+ $productSubs = Get-AzApiManagementSubscription - Context $context - ProductId $subs [0 ].ProductId
1136
+
1137
+ Assert-AreEqual 2 $productSubs.Count
1138
+ for ($i = 0 ; $i -lt $productSubs.Count ; $i ++ )
1139
+ {
1140
+ Assert-NotNull $productSubs [$i ]
1141
+ Assert-NotNull $productSubs [$i ].SubscriptionId
1142
+ Assert-NotNull $productSubs [$i ].Scope
1143
+ Assert-NotNull $productSubs [$i ].State
1144
+ Assert-NotNull $productSubs [$i ].CreatedDate
1145
+ Assert-NotNull $productSubs [$i ].PrimaryKey
1146
+ Assert-NotNull $productSubs [$i ].SecondaryKey
1147
+
1148
+ Assert-AreEqual $subs [0 ].ProductId $productSubs [$i ].ProductId
1149
+ }
1150
+
1151
+ # Get subscriptions by user id
1152
+ $userSubs = Get-AzApiManagementSubscription - Context $context - UserId $subs [0 ].UserId
1153
+
1154
+ Assert-AreEqual 3 $userSubs.Count
1155
+ for ($i = 0 ; $i -lt $userSubs.Count ; $i ++ )
1156
+ {
1157
+ Assert-NotNull $userSubs [$i ]
1158
+ Assert-NotNull $userSubs [$i ].SubscriptionId
1159
+ Assert-NotNull $userSubs [$i ].Scope
1160
+ Assert-NotNull $userSubs [$i ].State
1161
+ Assert-NotNull $userSubs [$i ].CreatedDate
1162
+ Assert-NotNull $userSubs [$i ].PrimaryKey
1163
+ Assert-NotNull $userSubs [$i ].SecondaryKey
1164
+
1165
+ Assert-AreEqual $subs [0 ].UserId $userSubs [$i ].UserId
1166
+ }
1167
+
1168
+ # get Subscriptions by User and Product
1169
+ $productUserSubs = Get-AzApiManagementSubscription - Context $context - UserId $subs [0 ].UserId - ProductId $subs [0 ].ProductId
1170
+
1171
+ Assert-AreEqual 2 $productUserSubs.Count
1172
+ for ($i = 0 ; $i -lt $productUserSubs.Count ; $i ++ )
1173
+ {
1174
+ Assert-NotNull $productUserSubs [$i ]
1175
+ Assert-NotNull $productUserSubs [$i ].SubscriptionId
1176
+ Assert-NotNull $productUserSubs [$i ].Scope
1177
+ Assert-NotNull $productUserSubs [$i ].State
1178
+ Assert-NotNull $productUserSubs [$i ].CreatedDate
1179
+ Assert-NotNull $productUserSubs [$i ].PrimaryKey
1180
+ Assert-NotNull $productUserSubs [$i ].SecondaryKey
1181
+
1182
+ Assert-AreEqual $subs [0 ].UserId $productUserSubs [$i ].UserId
1183
+ Assert-AreEqual $subs [0 ].ProductId $productUserSubs [$i ].ProductId
1184
+ }
1133
1185
}
1134
1186
finally {
1135
1187
# remove created subscription
@@ -1221,6 +1273,18 @@ function SubscriptionNewModel-CrudTest {
1221
1273
Assert-AreEqual 1 $sub.UserId
1222
1274
Assert-NotNull $sub.OwnerId
1223
1275
1276
+ # get subscription by apiId
1277
+ $sub = Get-AzApiManagementSubscription - Context $context - Scope $allApisScope
1278
+
1279
+ Assert-AreEqual $newSubscriptionId $sub.SubscriptionId
1280
+ Assert-AreEqual $patchedName $sub.Name
1281
+ Assert-AreEqual $patchedPk $sub.PrimaryKey
1282
+ Assert-AreEqual $patchedSk $sub.SecondaryKey
1283
+ Assert-AreEqual $newSubscriptionState $sub.State
1284
+ Assert-AreEqual $patchedExpirationDate $sub.ExpirationDate
1285
+ Assert-NotNull $sub.UserId
1286
+ Assert-AreEqual 1 $sub.UserId
1287
+ Assert-NotNull $sub.OwnerId
1224
1288
}
1225
1289
finally {
1226
1290
# remove created subscription
@@ -2886,7 +2950,8 @@ function ApiVersionSet-CrudTest {
2886
2950
# there should be no API Version sets initially
2887
2951
Assert-AreEqual 0 $apiversionsets.Count
2888
2952
2889
- # create new api
2953
+ # create new api and apiVersionSet
2954
+ $swaggerApiId1 = getAssetName
2890
2955
$newApiVersionSetId = getAssetName
2891
2956
try {
2892
2957
$newVersionSetName = getAssetName
@@ -2921,8 +2986,24 @@ function ApiVersionSet-CrudTest {
2921
2986
Assert-AreEqual $description $newApiVersionSet.Description
2922
2987
Assert-AreEqual Header $newApiVersionSet.VersioningScheme
2923
2988
Assert-AreEqual $versionHeaderName $newApiVersionSet.VersionHeaderName
2989
+
2990
+ # now import an api into the ApiVersionSet
2991
+ $swaggerPath = Join-Path (Join-Path " $TestOutputRoot " " Resources" ) " SwaggerPetStoreV2.json"
2992
+ $path1 = " swaggerapifromFile"
2993
+ $apiVersion = " 2"
2994
+
2995
+ $api = Import-AzApiManagementApi - Context $context - ApiId $swaggerApiId1 - SpecificationPath $swaggerPath - SpecificationFormat Swagger - Path $path1 - ApiVersion $apiVersion - ApiVersionSetId $newApiVersionSetId
2996
+ Assert-NotNull $api
2997
+ Assert-AreEqual $apiVersion $api.ApiVersion
2998
+ Assert-AreEqual $swaggerApiId1 $api.ApiId
2999
+ Assert-AreEqual $path1 $api.Path
3000
+ Assert-AreEqual $newApiVersionSet.Id $api.ApiVersionSetId
2924
3001
}
2925
3002
finally {
3003
+ # remove created api
3004
+ $removed = Remove-AzApiManagementApi - Context $context - ApiId $swaggerApiId1 - PassThru
3005
+ Assert-True { $removed }
3006
+
2926
3007
# remove created api version set
2927
3008
$removed = Remove-AzApiManagementApiVersionSet - Context $context - ApiVersionSetId $newApiVersionSetId - PassThru
2928
3009
Assert-True { $removed }
0 commit comments