Skip to content

Allow caller to Specify desired OutputType #499

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

Merged
merged 18 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 11 additions & 1 deletion .azure-pipelines/generate-auth-module-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
pwsh: true
script: |
Write-Host $(BUILDNUMBER)
pwsh $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -ArtifactsLocation $(Build.ArtifactStagingDirectory) -Build -ModulePreviewNumber $(BUILDNUMBER)
pwsh $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -ArtifactsLocation $(Build.ArtifactStagingDirectory) -Build -ModulePreviewNumber $(BUILDNUMBER) -Test

- task: DotNetCoreCLI@2
displayName: 'Run: Enabled Tests'
Expand Down Expand Up @@ -190,6 +190,16 @@ jobs:
packagesToPush: '$(Build.ArtifactStagingDirectory)\$(AUTH_MODULE_NAME)\Microsoft.Graph.$(AUTH_MODULE_NAME)*.nupkg'
publishVstsFeed: '0985d294-5762-4bc2-a565-161ef349ca3e/edc337b9-e5ea-49dd-a2cb-e8d66668ca57'
allowPackageConflicts: true

- task: PublishTestResults@2
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: '**/*-TestResults.xml'

- task: PublishCodeCoverageResults@1
inputs:
#codeCoverageTool: 'JaCoCo' # Options: cobertura, jaCoCo
summaryFileLocation: "**/coverage.xml"

- task: PublishBuildArtifacts@1
displayName: Publish Artifact Microsoft.Graph.Authentication.nupkg'
Expand Down
25 changes: 25 additions & 0 deletions .azure-pipelines/integrated-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,31 @@ stages:
Write-Host $(BUILDNUMBER)
printenv

- stage: GetSecrets
displayName: 'Get Secrets From Azure KeyVault'
jobs:
- job: GetSecrets
steps:
- task: AzureKeyVault@1
inputs:
azureSubscription: 'Microsoft Graph Build Agents'
KeyVaultName: 'msgraph-build-vault'
SecretsFilter: '*'
RunAsPreJob: true

- task: PowerShell@2
displayName: 'Install Test Certificate'
inputs:
targetType: 'inline'
script: |
$kvSecretBytes = [System.Convert]::FromBase64String('$(MsGraphPSSDKCertificate)')
$certCollection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
$certCollection.Import($kvSecretBytes,$null,[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store("My", "CurrentUser")
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
$store.AddRange($certCollection)
$store.Close()

- stage: SecurityPreChecks
displayName: 'Security Pre Checks'
jobs:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,7 @@ MigrationBackup/
.ionide/

# Visual Studio Code
.vscode/
.vscode/

#Custom Environment Files
localenv.json
1 change: 1 addition & 0 deletions Nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<configuration>
<packageSources>
<clear />
<add key="Nuget" value="https://api.nuget.org/v3/index.json" />
<add key="PowerShellSDK_BuildFeed" value="https://pkgs.dev.azure.com/microsoftgraph/0985d294-5762-4bc2-a565-161ef349ca3e/_packaging/PowerShellSDK_BuildFeed/nuget/v3/index.json" />
<add key="LocalNugetFeed" value="https://pkgs.dev.azure.com/microsoftgraph/0985d294-5762-4bc2-a565-161ef349ca3e/_packaging/b395d603-5c77-4af9-a495-1e3cdbb49e1e/nuget/v2" />
</packageSources>
Expand Down
56 changes: 37 additions & 19 deletions src/Authentication/Authentication.Test/Helpers/StringUtilTests.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,55 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.Graph.Authentication.Test.Helpers
{

using Microsoft.Graph.PowerShell.Authentication.Helpers;
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation;

using Xunit;
using Microsoft.Graph.PowerShell.Authentication.Helpers;

using Xunit;

namespace Microsoft.Graph.Authentication.Test.Helpers
{
public class StringUtilTests
{
private const string TestJsonArray = "{\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#users\"," + "\"value\": [{\"id\": \"6e7b768e-07e2-4810-8459-485f84f8f204\"},{\"id\": \"87d349ed-44d7-43e1-9a83-5f2406dee5bd\"}]}";

private const string TestJsonObject = "{\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#users/$entity\",\"businessPhones\": [\"+1 412 555 0109\"],\"displayName\": \"Megan Bowen\",\"givenName\": \"Megan\",\"jobTitle\": \"Auditor\",\"mail\": \"[email protected]\", \"mobilePhone\": null, \"officeLocation\": \"12/1110\",\"preferredLanguage\": \"en-US\",\"surname\": \"Bowen\",\"userPrincipalName\": \"[email protected]\",\"id\": \"48d31887-5fad-4d73-a9f5-3c356e68a038\"}";
public static IEnumerable<object[]> TestJsonData =>
new List<object[]>
{
new object[] { TestJsonArray},
new object[] { TestJsonObject}
};

[Theory]
[MemberData(nameof(TestJsonData))]
public void ShouldReturnCaseInsensitiveDictionaries(string jsonString)
{
Exception ex = null;
var converted = jsonString.TryConvertToJson(out var jsonObj, ref ex);
var hashTable = jsonString.ConvertFromJson(true, null, out _);

Assert.True(converted);
Assert.IsType<Hashtable>(jsonObj);
var jsonHashTable = (Hashtable)jsonObj;
Assert.NotNull(hashTable);
var jsonHashTable = (Hashtable)hashTable;
Assert.Equal(jsonHashTable["Value"], jsonHashTable["value"]);
}
public static IEnumerable<object[]> TestJsonData =>
new List<object[]>
{
new object[] { TestJsonArray},
new object[] { TestJsonObject}
};

[Theory]
[MemberData(nameof(TestJsonData))]
public void ShouldReturnPsObject(string jsonString)
{
var psObject = jsonString.ConvertFromJson(false, null, out _);

Assert.NotNull(psObject);
Assert.IsType<PSObject>(psObject);
}

[Theory]
[MemberData(nameof(TestJsonData))]
public void ShouldReturnHashTable(string jsonString)
{
var hashTable = jsonString.ConvertFromJson(true, null, out _);

Assert.NotNull(hashTable);
Assert.IsType<Hashtable>(hashTable);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<!-- As described in this post https://devblogs.microsoft.com/powershell/depending-on-the-right-powershell-nuget-package-in-your-net-project, reference the SDK for dotnetcore-->
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.2.7" PrivateAssets="all" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
Expand Down
Loading