Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix serialization of OpenTypes #1303

Merged
merged 5 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .azure-pipelines/generate-modules-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
pwsh: true
script: |
Write-Host $(BUILDNUMBER)
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -ArtifactsLocation $(Build.ArtifactStagingDirectory)\ -Build -EnableSigning -ModulePreviewNumber $(BUILDNUMBER) -RepositoryName "LocalNugetFeed" -ExcludeExampleTemplates -ExcludeNotesSection
. $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -ArtifactsLocation $(Build.ArtifactStagingDirectory)\ -Build -Test -EnableSigning -ModulePreviewNumber $(BUILDNUMBER) -RepositoryName "LocalNugetFeed" -ExcludeExampleTemplates -ExcludeNotesSection

- template: ./generation-templates/generate-helpdocs-template.yml

Expand Down
4 changes: 2 additions & 2 deletions .azure-pipelines/integrated-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ stages:
KEYVAULT: $(KEYVAULT)
AZURESUBSCRIPTION: $(AZURESUBSCRIPTION)

- stage: GenerateBetaModules
displayName: 'Generate Beta Modules (Microsoft.Graph.*)'
- stage: GenerateModules
displayName: 'Generate Modules (Microsoft.Graph.*)'
jobs:
- template: ./generate-modules-template.yml
parameters:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"New-MgIdentityConditionalAccessNamedLocation+[NoContext]+ShouldCreateAnIpNamedLocation+$POST+https://graph.microsoft.com/beta/identity/conditionalAccess/namedLocations+1": {
"Request": {
"Method": "POST",
"RequestUri": "https://graph.microsoft.com/beta/identity/conditionalAccess/namedLocations",
"Content": "{\r\n \"isTrusted\": false,\r\n \"ipRanges\": [\r\n {\r\n \"CidrAddress\": \"12.34.221.11/22\",\r\n \"@odata.type\": \"#microsoft.graph.iPv4CidrRange\"\r\n },\r\n {\r\n \"CidrAddress\": \"2001:0:9d38:90d6:0:0:0:0/63\",\r\n \"@odata.type\": \"#microsoft.graph.iPv6CidrRange\"\r\n }\r\n ],\r\n \"@odata.type\": \"#microsoft.graph.ipNamedLocation\",\r\n \"displayName\": \"Untrusted IP named location\"\r\n}",
"Headers": {
},
"ContentHeaders": {
"Content-Type": [ "application/json" ],
"Content-Length": [ "385" ]
}
},
"Response": {
"StatusCode": 201,
"Headers": {
"Cache-Control": [ "no-cache" ],
"Transfer-Encoding": [ "chunked" ],
"Location": [ "https://na.prod.graph.ipc.msidentity.com/conditionalAccess/namedLocations(\u0027013cca62-944c-462b-8fe7-8d51533b2ce3\u0027)" ],
"Vary": [ "Accept-Encoding" ],
"Strict-Transport-Security": [ "max-age=31536000" ],
"request-id": [ "3301729e-ec41-4cbc-9ba4-ef367483c104" ],
"client-request-id": [ "3301729e-ec41-4cbc-9ba4-ef367483c104" ],
"x-ms-ags-diagnostic": [ "{\"ServerInfo\":{\"DataCenter\":\"West US 2\",\"Slice\":\"E\",\"Ring\":\"1\",\"ScaleUnit\":\"001\",\"RoleInstance\":\"MW2PEPF00009118\"}}" ],
"OData-Version": [ "4.0" ],
"Date": [ "Fri, 03 Jun 2022 19:24:13 GMT" ]
},
"ContentHeaders": {
"Content-Type": [ "application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8" ],
"Content-Encoding": [ "gzip" ]
},
"Content": "{\"@odata.context\":\"https://graph.microsoft.com/beta/$metadata#identity/conditionalAccess/namedLocations/$entity\",\"@odata.type\":\"#microsoft.graph.ipNamedLocation\",\"id\":\"013cca62-944c-462b-8fe7-8d51533b2ce3\",\"displayName\":\"Untrusted IP named location\",\"modifiedDateTime\":\"2022-06-03T19:24:12.9772062Z\",\"createdDateTime\":\"2022-06-03T19:24:12.9772062Z\",\"isTrusted\":false,\"ipRanges\":[{\"@odata.type\":\"#microsoft.graph.iPv4CidrRange\",\"cidrAddress\":\"12.34.221.11/22\"},{\"@odata.type\":\"#microsoft.graph.iPv6CidrRange\",\"cidrAddress\":\"2001:0:9d38:90d6:0:0:0:0/63\"}]}"
}
},
"New-MgIdentityConditionalAccessNamedLocation+[NoContext]+ShouldCreateACountryNamedLocation+$POST+https://graph.microsoft.com/beta/identity/conditionalAccess/namedLocations+1": {
"Request": {
"Method": "POST",
"RequestUri": "https://graph.microsoft.com/beta/identity/conditionalAccess/namedLocations",
"Content": "{\r\n \"countriesAndRegions\": [ \"US\", \"GB\" ],\r\n \"includeUnknownCountriesAndRegions\": true,\r\n \"@odata.type\": \"#microsoft.graph.countryNamedLocation\",\r\n \"displayName\": \"Named location with unknown countries and regions\"\r\n}",
"Headers": {
},
"ContentHeaders": {
"Content-Type": [ "application/json" ],
"Content-Length": [ "221" ]
}
},
"Response": {
"StatusCode": 201,
"Headers": {
"Cache-Control": [ "no-cache" ],
"Transfer-Encoding": [ "chunked" ],
"Location": [ "https://na.prod.graph.ipc.msidentity.com/conditionalAccess/namedLocations(\u00271aefaad3-f427-4c97-9683-fead95178e99\u0027)" ],
"Vary": [ "Accept-Encoding" ],
"Strict-Transport-Security": [ "max-age=31536000" ],
"request-id": [ "92a311dd-5cc9-4756-b9cf-bbda241d2307" ],
"client-request-id": [ "92a311dd-5cc9-4756-b9cf-bbda241d2307" ],
"x-ms-ags-diagnostic": [ "{\"ServerInfo\":{\"DataCenter\":\"West US 2\",\"Slice\":\"E\",\"Ring\":\"1\",\"ScaleUnit\":\"001\",\"RoleInstance\":\"MW2PEPF00009118\"}}" ],
"OData-Version": [ "4.0" ],
"Date": [ "Fri, 03 Jun 2022 19:24:15 GMT" ]
},
"ContentHeaders": {
"Content-Type": [ "application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8" ],
"Content-Encoding": [ "gzip" ]
},
"Content": "{\"@odata.context\":\"https://graph.microsoft.com/beta/$metadata#identity/conditionalAccess/namedLocations/$entity\",\"@odata.type\":\"#microsoft.graph.countryNamedLocation\",\"id\":\"1aefaad3-f427-4c97-9683-fead95178e99\",\"displayName\":\"Named location with unknown countries and regions\",\"modifiedDateTime\":\"2022-06-03T19:24:14.6544147Z\",\"createdDateTime\":\"2022-06-03T19:24:14.6544147Z\",\"countriesAndRegions\":[\"US\",\"GB\"],\"includeUnknownCountriesAndRegions\":true,\"countryLookupMethod\":\"clientIpAddress\"}"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,76 @@
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
if (-Not (Test-Path -Path $loadEnvPath)) {
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
}
. ($loadEnvPath)
$TestRecordingFile = Join-Path $PSScriptRoot 'New-MgIdentityConditionalAccessNamedLocation.Recording.json'
$currentPath = $PSScriptRoot
while(-not $mockingPath) {
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
$currentPath = Split-Path -Path $currentPath -Parent
BeforeAll {
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
if (-Not (Test-Path -Path $loadEnvPath)) {
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
}
. ($loadEnvPath)
# Set test mode to playback.
$TestMode = 'playback'
$TestRecordingFile = Join-Path $PSScriptRoot 'New-MgIdentityConditionalAccessNamedLocation.Recording.json'
$currentPath = $PSScriptRoot
while(-not $mockingPath) {
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
$currentPath = Split-Path -Path $currentPath -Parent
}
. ($mockingPath | Select-Object -First 1).FullName

Select-MgProfile 'beta'
}
. ($mockingPath | Select-Object -First 1).FullName

Describe 'New-MgIdentityConditionalAccessNamedLocation' {
It 'CreateExpanded1' -skip {
{ throw [System.NotImplementedException] } | Should -Not -Throw
BeforeAll {
$Mock.PushDescription('New-MgIdentityConditionalAccessNamedLocation')
}

It 'Create1' -skip {
{ throw [System.NotImplementedException] } | Should -Not -Throw
Context 'Create' {
It 'Should create an ipNamedLocation' {
$Mock.PushScenario('ShouldCreateAnIpNamedLocation')
$params = @{
"@odata.type" = "#microsoft.graph.ipNamedLocation"
DisplayName = "Untrusted IP named location"
IsTrusted = $false
IpRanges = @(
@{
"@odata.type" = "#microsoft.graph.iPv4CidrRange"
CidrAddress = "12.34.221.11/22"
}
@{
"@odata.type" = "#microsoft.graph.iPv6CidrRange"
CidrAddress = "2001:0:9d38:90d6:0:0:0:0/63"
}
)
}

# Redirect debug stream to variable.
$IpNamedLocation = New-MgIdentityConditionalAccessNamedLocation -BodyParameter $params -Debug -Confirm:$false 5>&1

$IpNamedLocation.DisplayName | Should -Be $params.DisplayName
$IpNamedLocation.AdditionalProperties.ipRanges | Should -HaveCount 2
$HttpRequestLog = $IpNamedLocation | Where-Object { $_ -Like "*HTTP REQUEST*" }
$HttpRequestLog.Message | Should -BeLikeExactly '*"isTrusted": false*'
$HttpRequestLog.Message | Should -BeLikeExactly '*"ipRanges":*'
}

It 'Should create a countryNamedLocation' {
$Mock.PushScenario('ShouldCreateACountryNamedLocation')
$params = @{
"@odata.type" = "#microsoft.graph.countryNamedLocation"
DisplayName = "Named location with unknown countries and regions"
CountriesAndRegions = @(
"US"
"GB"
)
IncludeUnknownCountriesAndRegions = $true
}

# Redirect debug stream to variable.
$CountryNamedLocation = New-MgIdentityConditionalAccessNamedLocation -BodyParameter $params -Debug -Confirm:$false 5>&1

$CountryNamedLocation.DisplayName | Should -Be $params.DisplayName
$CountryNamedLocation.AdditionalProperties.countriesAndRegions | Should -HaveCount 2
$HttpRequestLog = $CountryNamedLocation | Where-Object { $_ -Like "*HTTP REQUEST*" }
$HttpRequestLog.Message | Should -BeLikeExactly '*"includeUnknownCountriesAndRegions": true*'
$HttpRequestLog.Message | Should -BeLikeExactly '*"countriesAndRegions":*'
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"New-MgIdentityConditionalAccessNamedLocation+[NoContext]+ShouldCreateAnIpNamedLocation+$POST+https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations+1": {
"Request": {
"Method": "POST",
"RequestUri": "https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations",
"Content": "{\r\n \"isTrusted\": false,\r\n \"ipRanges\": [\r\n {\r\n \"CidrAddress\": \"12.34.221.11/22\",\r\n \"@odata.type\": \"#microsoft.graph.iPv4CidrRange\"\r\n },\r\n {\r\n \"CidrAddress\": \"2001:0:9d38:90d6:0:0:0:0/63\",\r\n \"@odata.type\": \"#microsoft.graph.iPv6CidrRange\"\r\n }\r\n ],\r\n \"@odata.type\": \"#microsoft.graph.ipNamedLocation\",\r\n \"displayName\": \"Untrusted IP named location\"\r\n}",
"Headers": {
},
"ContentHeaders": {
"Content-Type": [ "application/json" ],
"Content-Length": [ "385" ]
}
},
"Response": {
"StatusCode": 201,
"Headers": {
"Cache-Control": [ "no-cache" ],
"Transfer-Encoding": [ "chunked" ],
"Location": [ "https://na.prod.graph.ipc.msidentity.com/conditionalAccess/namedLocations(\u002700eabbed-3856-479e-8de4-c2c4bd1768c1\u0027)" ],
"Vary": [ "Accept-Encoding" ],
"Strict-Transport-Security": [ "max-age=31536000" ],
"request-id": [ "17f9929b-59d6-480a-aaeb-c9e121e93c7b" ],
"client-request-id": [ "17f9929b-59d6-480a-aaeb-c9e121e93c7b" ],
"x-ms-ags-diagnostic": [ "{\"ServerInfo\":{\"DataCenter\":\"West US 2\",\"Slice\":\"E\",\"Ring\":\"1\",\"ScaleUnit\":\"001\",\"RoleInstance\":\"MW2PEPF00009119\"}}" ],
"OData-Version": [ "4.0" ],
"Date": [ "Fri, 03 Jun 2022 19:23:59 GMT" ]
},
"ContentHeaders": {
"Content-Type": [ "application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8" ],
"Content-Encoding": [ "gzip" ]
},
"Content": "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#identity/conditionalAccess/namedLocations/$entity\",\"@odata.type\":\"#microsoft.graph.ipNamedLocation\",\"id\":\"00eabbed-3856-479e-8de4-c2c4bd1768c1\",\"displayName\":\"Untrusted IP named location\",\"modifiedDateTime\":\"2022-06-03T19:23:59.6882138Z\",\"createdDateTime\":\"2022-06-03T19:23:59.6882138Z\",\"isTrusted\":false,\"ipRanges\":[{\"@odata.type\":\"#microsoft.graph.iPv4CidrRange\",\"cidrAddress\":\"12.34.221.11/22\"},{\"@odata.type\":\"#microsoft.graph.iPv6CidrRange\",\"cidrAddress\":\"2001:0:9d38:90d6:0:0:0:0/63\"}]}"
}
},
"New-MgIdentityConditionalAccessNamedLocation+[NoContext]+ShouldCreateACountryNamedLocation+$POST+https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations+1": {
"Request": {
"Method": "POST",
"RequestUri": "https://graph.microsoft.com/v1.0/identity/conditionalAccess/namedLocations",
"Content": "{\r\n \"countriesAndRegions\": [ \"US\", \"GB\" ],\r\n \"includeUnknownCountriesAndRegions\": true,\r\n \"@odata.type\": \"#microsoft.graph.countryNamedLocation\",\r\n \"displayName\": \"Named location with unknown countries and regions\"\r\n}",
"Headers": {
},
"ContentHeaders": {
"Content-Type": [ "application/json" ],
"Content-Length": [ "221" ]
}
},
"Response": {
"StatusCode": 201,
"Headers": {
"Cache-Control": [ "no-cache" ],
"Transfer-Encoding": [ "chunked" ],
"Location": [ "https://na.prod.graph.ipc.msidentity.com/conditionalAccess/namedLocations(\u00271c14a6aa-4e2a-44b4-8ba8-ada756528559\u0027)" ],
"Vary": [ "Accept-Encoding" ],
"Strict-Transport-Security": [ "max-age=31536000" ],
"request-id": [ "80c7c0c1-dce3-459c-94f1-2156fbd1540f" ],
"client-request-id": [ "80c7c0c1-dce3-459c-94f1-2156fbd1540f" ],
"x-ms-ags-diagnostic": [ "{\"ServerInfo\":{\"DataCenter\":\"West US 2\",\"Slice\":\"E\",\"Ring\":\"1\",\"ScaleUnit\":\"001\",\"RoleInstance\":\"MW2PEPF00009119\"}}" ],
"OData-Version": [ "4.0" ],
"Date": [ "Fri, 03 Jun 2022 19:24:01 GMT" ]
},
"ContentHeaders": {
"Content-Type": [ "application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8" ],
"Content-Encoding": [ "gzip" ]
},
"Content": "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#identity/conditionalAccess/namedLocations/$entity\",\"@odata.type\":\"#microsoft.graph.countryNamedLocation\",\"id\":\"1c14a6aa-4e2a-44b4-8ba8-ada756528559\",\"displayName\":\"Named location with unknown countries and regions\",\"modifiedDateTime\":\"2022-06-03T19:24:01.5082252Z\",\"createdDateTime\":\"2022-06-03T19:24:01.5082252Z\",\"countriesAndRegions\":[\"US\",\"GB\"],\"includeUnknownCountriesAndRegions\":true,\"countryLookupMethod\":\"clientIpAddress\"}"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,76 @@
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
if (-Not (Test-Path -Path $loadEnvPath)) {
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
}
. ($loadEnvPath)
$TestRecordingFile = Join-Path $PSScriptRoot 'New-MgIdentityConditionalAccessNamedLocation.Recording.json'
$currentPath = $PSScriptRoot
while(-not $mockingPath) {
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
$currentPath = Split-Path -Path $currentPath -Parent
BeforeAll {
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
if (-Not (Test-Path -Path $loadEnvPath)) {
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
}
. ($loadEnvPath)
# Set test mode to playback.
$TestMode = 'playback'
$TestRecordingFile = Join-Path $PSScriptRoot 'New-MgIdentityConditionalAccessNamedLocation.Recording.json'
$currentPath = $PSScriptRoot
while(-not $mockingPath) {
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
$currentPath = Split-Path -Path $currentPath -Parent
}
. ($mockingPath | Select-Object -First 1).FullName

Select-MgProfile 'v1.0'
}
. ($mockingPath | Select-Object -First 1).FullName

Describe 'New-MgIdentityConditionalAccessNamedLocation' {
It 'CreateExpanded' -skip {
{ throw [System.NotImplementedException] } | Should -Not -Throw
BeforeAll {
$Mock.PushDescription('New-MgIdentityConditionalAccessNamedLocation')
}

It 'Create' -skip {
{ throw [System.NotImplementedException] } | Should -Not -Throw
Context 'Create' {
It 'Should create an ipNamedLocation' {
$Mock.PushScenario('ShouldCreateAnIpNamedLocation')
$params = @{
"@odata.type" = "#microsoft.graph.ipNamedLocation"
DisplayName = "Untrusted IP named location"
IsTrusted = $false
IpRanges = @(
@{
"@odata.type" = "#microsoft.graph.iPv4CidrRange"
CidrAddress = "12.34.221.11/22"
}
@{
"@odata.type" = "#microsoft.graph.iPv6CidrRange"
CidrAddress = "2001:0:9d38:90d6:0:0:0:0/63"
}
)
}

# Redirect debug stream to variable.
$IpNamedLocation = New-MgIdentityConditionalAccessNamedLocation -BodyParameter $params -Debug -Confirm:$false 5>&1

$IpNamedLocation.DisplayName | Should -Be $params.DisplayName
$IpNamedLocation.AdditionalProperties.ipRanges | Should -HaveCount 2
$HttpRequestLog = $IpNamedLocation | Where-Object { $_ -Like "*HTTP REQUEST*" }
$HttpRequestLog.Message | Should -BeLikeExactly '*"isTrusted": false*'
$HttpRequestLog.Message | Should -BeLikeExactly '*"ipRanges":*'
}

It 'Should create a countryNamedLocation' {
$Mock.PushScenario('ShouldCreateACountryNamedLocation')
$params = @{
"@odata.type" = "#microsoft.graph.countryNamedLocation"
DisplayName = "Named location with unknown countries and regions"
CountriesAndRegions = @(
"US"
"GB"
)
IncludeUnknownCountriesAndRegions = $true
}

# Redirect debug stream to variable.
$CountryNamedLocation = New-MgIdentityConditionalAccessNamedLocation -BodyParameter $params -Debug -Confirm:$false 5>&1

$CountryNamedLocation.DisplayName | Should -Be $params.DisplayName
$CountryNamedLocation.AdditionalProperties.countriesAndRegions | Should -HaveCount 2
$HttpRequestLog = $CountryNamedLocation | Where-Object { $_ -Like "*HTTP REQUEST*" }
$HttpRequestLog.Message | Should -BeLikeExactly '*"includeUnknownCountriesAndRegions": true*'
$HttpRequestLog.Message | Should -BeLikeExactly '*"countriesAndRegions":*'
}
}
}
Loading