Skip to content

Commit 5f1e40b

Browse files
authored
Merge pull request #2661 from microsoftgraph/2645-set-mguserphotocontent-not-working-in-powershell-5
Makes ``Set-MgUserPhotoContent`` compatible with both PS Core and PS Desktop
2 parents 743f1ba + d68f499 commit 5f1e40b

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

src/Users/v1.0/test/Langchain.jpg

9.14 KB
Loading
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"Set-MgUserPhotoContent+[NoContext]+ShouldUpdatePhoto+$PUT+https://graph.microsoft.com/v1.0/users/contoso@micorosoft.com/photo/$value": {
3+
"Request": {
4+
"Method": "PUT",
5+
"Body": "binary data",
6+
"Headers": {
7+
"Content-Type": "image/jpg"
8+
}
9+
},
10+
"Response": {
11+
"StatusCode": 200,
12+
"Headers": {
13+
"Strict-Transport-Security": [
14+
"max-age=31536000"
15+
],
16+
"request-id": [
17+
"ceec1bb3-bfe4-4f4c-9bba-b47f18ab1372"
18+
],
19+
"client-request-id": [
20+
"7f583ee0-9357-4c32-84df-25f1d7f05636"
21+
],
22+
"x-ms-ags-diagnostic": [
23+
"{\"ServerInfo\":{\"DataCenter\":\"West US 2\",\"Slice\":\"E\",\"Ring\":\"1\",\"ScaleUnit\":\"001\",\"RoleInstance\":\"MW2PEPF0000749D\"}}"
24+
],
25+
"Date": [
26+
"Thu, 04 Jun 2024 16:33:12 GMT"
27+
]
28+
}
29+
}
30+
}
31+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
if (($null -eq $TestName) -or ($TestName -contains 'Set-MgUserPhotoContent')) {
2+
$TestMode = 'playback'
3+
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
4+
if (-Not (Test-Path -Path $loadEnvPath)) {
5+
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
6+
}
7+
. ($loadEnvPath)
8+
$TestRecordingFile = Join-Path $PSScriptRoot 'Set-MgUserPhotoContent.Recording.json'
9+
$currentPath = $PSScriptRoot
10+
while (-not $mockingPath) {
11+
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
12+
$currentPath = Split-Path -Path $currentPath -Parent
13+
}
14+
. ($mockingPath | Select-Object -First 1).FullName
15+
}
16+
17+
Describe 'Set-MgUserPhotoContent' {
18+
BeforeAll {
19+
$Mock.PushDescription('Set-MgUserPhotoContent')
20+
}
21+
Context 'Update' {
22+
It 'ShouldUpdatePhoto' {
23+
$Mock.PushScenario('ShouldUpdatePhoto')
24+
{ Set-MgUserPhotoContent -UserId contoso@microsoft.com -InFile "src\Users\v1.0\test\Langchain.jpg" } | Should -Not -Throw
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)