Skip to content

Commit

Permalink
Merge pull request #2661 from microsoftgraph/2645-set-mguserphotocont…
Browse files Browse the repository at this point in the history
…ent-not-working-in-powershell-5

Makes ``Set-MgUserPhotoContent`` compatible with both PS Core and PS Desktop
  • Loading branch information
timayabi2020 authored Apr 5, 2024
2 parents 743f1ba + d68f499 commit 5f1e40b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
Binary file added src/Users/v1.0/test/Langchain.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/Users/v1.0/test/Set-MgUserPhotoContent.Recording.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"Set-MgUserPhotoContent+[NoContext]+ShouldUpdatePhoto+$PUT+https://graph.microsoft.com/v1.0/users/contoso@micorosoft.com/photo/$value": {
"Request": {
"Method": "PUT",
"Body": "binary data",
"Headers": {
"Content-Type": "image/jpg"
}
},
"Response": {
"StatusCode": 200,
"Headers": {
"Strict-Transport-Security": [
"max-age=31536000"
],
"request-id": [
"ceec1bb3-bfe4-4f4c-9bba-b47f18ab1372"
],
"client-request-id": [
"7f583ee0-9357-4c32-84df-25f1d7f05636"
],
"x-ms-ags-diagnostic": [
"{\"ServerInfo\":{\"DataCenter\":\"West US 2\",\"Slice\":\"E\",\"Ring\":\"1\",\"ScaleUnit\":\"001\",\"RoleInstance\":\"MW2PEPF0000749D\"}}"
],
"Date": [
"Thu, 04 Jun 2024 16:33:12 GMT"
]
}
}
}
}
27 changes: 27 additions & 0 deletions src/Users/v1.0/test/Set-MgUserPhotoContent.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
if (($null -eq $TestName) -or ($TestName -contains 'Set-MgUserPhotoContent')) {
$TestMode = 'playback'
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
if (-Not (Test-Path -Path $loadEnvPath)) {
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
}
. ($loadEnvPath)
$TestRecordingFile = Join-Path $PSScriptRoot 'Set-MgUserPhotoContent.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
}

Describe 'Set-MgUserPhotoContent' {
BeforeAll {
$Mock.PushDescription('Set-MgUserPhotoContent')
}
Context 'Update' {
It 'ShouldUpdatePhoto' {
$Mock.PushScenario('ShouldUpdatePhoto')
{ Set-MgUserPhotoContent -UserId contoso@microsoft.com -InFile "src\Users\v1.0\test\Langchain.jpg" } | Should -Not -Throw
}
}
}

0 comments on commit 5f1e40b

Please sign in to comment.