Skip to content

Commit bd0b988

Browse files
committed
Resolve namespaces.
1 parent 7465e71 commit bd0b988

25 files changed

+74
-45
lines changed

src/Authentication/Authentication.Test/Common/GraphSettingsTests.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
using Microsoft.Graph.Authentication.Test.Mocks;
44
using Microsoft.Graph.PowerShell.Authentication;
55
using Microsoft.Graph.PowerShell.Authentication.Common;
6-
using System;
7-
using System.Collections.Generic;
8-
using System.IO;
6+
using Microsoft.Graph.PowerShell.Authentication.Interfaces;
7+
using Microsoft.Graph.PowerShell.Authentication.Models;
98
using System.Linq;
10-
using System.Runtime.Serialization.Formatters.Binary;
11-
using System.Text;
129
using Xunit;
1310

1411
public class GraphSettingsTests

src/Authentication/Authentication.Test/Handlers/NationalCloudHandlerTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ namespace Microsoft.Graph.Authentication.Test
22
{
33
using Microsoft.Graph.PowerShell.Authentication;
44
using Microsoft.Graph.PowerShell.Authentication.Handlers;
5+
using Microsoft.Graph.PowerShell.Authentication.Models;
56
using System;
6-
using System.Linq;
77
using System.Net.Http;
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Xunit;
11+
1112
public class NationalCloudHandlerTests : IDisposable
1213
{
1314
private HttpMessageInvoker _invoker;

src/Authentication/Authentication.Test/Mocks/MockDataStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Microsoft.Graph.Authentication.Test.Mocks
22
{
3-
using Microsoft.Graph.PowerShell.Authentication;
3+
using Microsoft.Graph.PowerShell.Authentication.Interfaces;
44
using System;
55
using System.Collections.Concurrent;
66
using System.Collections.Generic;

src/Authentication/Authentication.Test/TokenCache/ProcessTokenCacheStorageTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Microsoft.Graph.Authentication.Test.TokenCache
22
{
33
using Microsoft.Graph.PowerShell.Authentication;
4+
using Microsoft.Graph.PowerShell.Authentication.Common;
45
using Microsoft.Graph.PowerShell.Authentication.TokenCache;
56
using System;
67
using System.Text;

src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Microsoft.Graph.PowerShell.Authentication.Cmdlets
1616
using System.Threading.Tasks;
1717
using System.Net;
1818
using System.Globalization;
19+
using Microsoft.Graph.PowerShell.Authentication.Interfaces;
1920
using Microsoft.Graph.PowerShell.Authentication.Common;
2021

2122
[Cmdlet(VerbsCommunications.Connect, "MgGraph", DefaultParameterSetName = Constants.UserParameterSet)]
@@ -77,16 +78,6 @@ protected override void BeginProcessing()
7778
base.BeginProcessing();
7879
ValidateParameters();
7980

80-
if (GraphEnvironment.BuiltInEnvironments.ContainsKey(GraphEnvironmentConstants.EnvironmentName.Global))
81-
{
82-
environment = GraphEnvironment.BuiltInEnvironments[GraphEnvironmentConstants.EnvironmentName.Global];
83-
}
84-
else
85-
{
86-
WriteWarning($"Default environment {GraphEnvironmentConstants.EnvironmentName.Global} cannot be found from environment list.");
87-
WriteWarning("You can get current list via [Microsoft.Graph.PowerShell.Authentication.GraphEnvironment]::GraphEnvironments");
88-
}
89-
9081
if (MyInvocation.BoundParameters.ContainsKey(nameof(Environment)))
9182
{
9283
GraphSettings settings = this.GetContextSettings();
@@ -95,6 +86,10 @@ protected override void BeginProcessing()
9586
throw new PSInvalidOperationException(string.Format(ErrorConstants.Message.InvalidEnvironment, Environment));
9687
}
9788
}
89+
else
90+
{
91+
environment = GraphEnvironment.BuiltInEnvironments[GraphEnvironmentConstants.EnvironmentName.Global];
92+
}
9893
}
9994

10095
protected override void EndProcessing()

src/Authentication/Authentication/Cmdlets/Environment/AddMgEnvironment.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
namespace Microsoft.Graph.PowerShell.Authentication.Cmdlets
66
{
7+
using Microsoft.Graph.PowerShell.Authentication.Common;
78
using Microsoft.Graph.PowerShell.Authentication.Extensions;
89
using Microsoft.Graph.PowerShell.Authentication.Helpers;
10+
using Microsoft.Graph.PowerShell.Authentication.Interfaces;
11+
using Microsoft.Graph.PowerShell.Authentication.Models;
912
using System;
1013
using System.Linq;
1114
using System.Management.Automation;

src/Authentication/Authentication/Cmdlets/Environment/GetMgEnvironment.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Microsoft.Graph.PowerShell.Authentication.Cmdlets
66
{
7+
using Microsoft.Graph.PowerShell.Authentication.Common;
8+
using Microsoft.Graph.PowerShell.Authentication.Models;
79
using System.Management.Automation;
810

911
/// <summary>

src/Authentication/Authentication/Cmdlets/Environment/RemoveMgEnvironment.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace Microsoft.Graph.PowerShell.Authentication.Cmdlets
66
{
7+
using Microsoft.Graph.PowerShell.Authentication.Common;
78
using Microsoft.Graph.PowerShell.Authentication.Helpers;
9+
using Microsoft.Graph.PowerShell.Authentication.Models;
810
using System;
911
using System.Globalization;
1012
using System.Linq;

src/Authentication/Authentication/Cmdlets/Environment/SetMgEnvironment.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
namespace Microsoft.Graph.PowerShell.Authentication.Cmdlets
66
{
7+
using Microsoft.Graph.PowerShell.Authentication.Common;
78
using Microsoft.Graph.PowerShell.Authentication.Extensions;
9+
using Microsoft.Graph.PowerShell.Authentication.Interfaces;
10+
using Microsoft.Graph.PowerShell.Authentication.Models;
811
using System;
912
using System.Globalization;
1013
using System.Linq;
@@ -52,12 +55,7 @@ protected override void ProcessRecord()
5255
GraphSettings settings = this.GetContextSettings();
5356
if (!settings.TryGetEnvironment(Name, out IGraphEnvironment newEnvironment))
5457
{
55-
// Create default environment if it doesn't exist.
56-
newEnvironment = new GraphEnvironment {
57-
Name = Name,
58-
AzureADEndpoint = settings.EnvironmentTable[GraphEnvironmentConstants.EnvironmentName.Global].AzureADEndpoint,
59-
GraphEndpoint = settings.EnvironmentTable[GraphEnvironmentConstants.EnvironmentName.Global].GraphEndpoint
60-
};
58+
newEnvironment = new GraphEnvironment { Name = Name };
6159
}
6260

6361
if (MyInvocation.BoundParameters.ContainsKey(nameof(AzureADEndpoint)))
@@ -70,6 +68,7 @@ protected override void ProcessRecord()
7068
newEnvironment.GraphEndpoint = GraphEndpoint.GetBaseUrl();
7169
}
7270

71+
ValidateEnvironment(newEnvironment);
7372
newEnvironment.Type = GraphEnvironmentConstants.EnvironmentType.UserDefined;
7473
bool isSuccess = settings.TrySetEnvironment(newEnvironment, out IGraphEnvironment mergedEnvironment);
7574

@@ -83,6 +82,19 @@ protected override void ProcessRecord()
8382
}
8483
}
8584

85+
/// <summary>
86+
/// Ensures all required properties are set to <see cref="IGraphEnvironment"/> object.
87+
/// </summary>
88+
/// <param name="newEnvironment">The new <see cref="IGraphEnvironment"/> object.</param>
89+
private void ValidateEnvironment(IGraphEnvironment newEnvironment)
90+
{
91+
if (string.IsNullOrWhiteSpace(newEnvironment.AzureADEndpoint)
92+
|| string.IsNullOrWhiteSpace(newEnvironment.GraphEndpoint))
93+
{
94+
this.ThrowParameterError(ErrorConstants.Message.InvalidUrlParameter, $"{nameof(GraphEndpoint)} or {nameof(AzureADEndpoint)}");
95+
}
96+
}
97+
8698
private void ValidateParameters()
8799
{
88100
if (string.IsNullOrWhiteSpace(Name))

src/Authentication/Authentication/Cmdlets/InvokeMgGraphRequest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
using System.Threading;
1313
using Microsoft.Graph.PowerShell.Authentication.Extensions;
1414
using Microsoft.Graph.PowerShell.Authentication.Helpers;
15+
using Microsoft.Graph.PowerShell.Authentication.Interfaces;
1516
using Microsoft.Graph.PowerShell.Authentication.Models;
1617
using Microsoft.Graph.PowerShell.Authentication.Properties;
1718
using Microsoft.PowerShell.Commands;
18-
1919
using Newtonsoft.Json;
20-
2120
using DriveNotFoundException = System.Management.Automation.DriveNotFoundException;
2221

2322
namespace Microsoft.Graph.PowerShell.Authentication.Cmdlets

0 commit comments

Comments
 (0)