-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afc7d57
commit ef12dd4
Showing
237 changed files
with
9,087 additions
and
1,925 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -399,5 +399,8 @@ FodyWeavers.xsd | |
*.sln.iml | ||
.idea/ | ||
|
||
# VS Code | ||
.vscode/ | ||
|
||
# macOS | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,13 +65,13 @@ ugs deploy . | |
You will find all the contents deployed in your dashboard for the configured project and environment. The command deploys all the samples in current (`Deploy`) directory for supported services. | ||
|
||
--- | ||
[`deploy`]: /docs/deploy-command.md | ||
[`deploy`]: https://services.docs.unity.com/guides/ugs-cli/latest/general/base-commands/deploy | ||
[Remote Config files]: https://docs.unity3d.com/Packages/[email protected]/manual/Authoring/remote_config_files.html | ||
[Declare parameters in the script]: https://docs.unity.com/cloud-code/authoring-scripts-editor.html#Declare_parameters_in_the_script | ||
[Script.js]: /Samples/Deploy/CloudCode/Script.js | ||
[configuration.rc]: /Samples/Deploy/RemoteConfig/configuration.rc | ||
[Samples/Deploy]: /Samples/Deploy | ||
[Deploy Command]: /docs/project-roles.md#deploy-command | ||
[Deploy Command]: https://services.docs.unity.com/guides/ugs-cli/latest/general/troubleshooting/project-roles#deploy-command | ||
[Service Account]: https://services.docs.unity.com/docs/service-account-auth/index.html | ||
[Login]: /docs/module-authentication.md#login | ||
[configuration]: /docs/module-configuration.md#configuration-module | ||
[Login]: https://services.docs.unity.com/guides/ugs-cli/latest/general/base-commands/authentication/login | ||
[configuration]: https://services.docs.unity.com/guides/ugs-cli/latest/general/base-commands/configuration/configuration-keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
Unity.Services.Cli/Unity.Services.Cli.Access.UnitTest/AccessModuleTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
using System.CommandLine.Builder; | ||
using System.Reflection; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NUnit.Framework; | ||
using Unity.Services.Cli.Access.Input; | ||
using Unity.Services.Cli.Access.Service; | ||
using Unity.Services.Cli.Common; | ||
using Unity.Services.Cli.Common.Input; | ||
using Unity.Services.Cli.Common.Networking; | ||
using Unity.Services.Cli.TestUtils; | ||
using Unity.Services.Gateway.AccessApiV1.Generated.Api; | ||
|
||
namespace Unity.Services.Cli.Access.UnitTest; | ||
|
||
[TestFixture] | ||
public class AccessModuleTests | ||
{ | ||
private readonly AccessModule k_AccessModule = new(); | ||
|
||
[Test] | ||
public void BuildCommands_CreateCommands() | ||
{ | ||
var commandLineBuilder = new CommandLineBuilder(); | ||
commandLineBuilder.AddModule(k_AccessModule); | ||
TestsHelper.AssertContainsCommand(commandLineBuilder.Command, k_AccessModule.ModuleRootCommand!.Name, out var resultCommand); | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(resultCommand, Is.EqualTo(k_AccessModule.ModuleRootCommand)); | ||
Assert.That(k_AccessModule.GetPlayerPolicyCommand!.Handler, Is.Not.Null); | ||
Assert.That(k_AccessModule.GetProjectPolicyCommand!.Handler, Is.Not.Null); | ||
Assert.That(k_AccessModule.GetAllPlayerPoliciesCommand!.Handler, Is.Not.Null); | ||
Assert.That(k_AccessModule.UpsertProjectPolicyCommand!.Handler, Is.Not.Null); | ||
Assert.That(k_AccessModule.UpsertPlayerPolicyCommand!.Handler, Is.Not.Null); | ||
Assert.That(k_AccessModule.DeleteProjectPolicyStatementsCommand!.Handler, Is.Not.Null); | ||
Assert.That(k_AccessModule.ModuleRootCommand!.Aliases, Does.Contain("ac")); | ||
Assert.That(k_AccessModule.DeletePlayerPolicyStatementsCommand!.Handler, Is.Not.Null); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void GetProjectPolicyCommand_ContainsRequiredInputs() | ||
{ | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(k_AccessModule.GetProjectPolicyCommand!.Options, Does.Contain(CommonInput.CloudProjectIdOption)); | ||
Assert.That(k_AccessModule.GetProjectPolicyCommand!.Options, Does.Contain(CommonInput.EnvironmentNameOption)); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void GetPlayerPolicyCommand_ContainsRequiredInputs() | ||
{ | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(k_AccessModule.GetPlayerPolicyCommand!.Options, Does.Contain(CommonInput.CloudProjectIdOption)); | ||
Assert.That(k_AccessModule.GetPlayerPolicyCommand!.Options, Does.Contain(CommonInput.EnvironmentNameOption)); | ||
Assert.That(k_AccessModule.GetPlayerPolicyCommand.Arguments, Does.Contain(AccessInput.PlayerIdArgument)); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void GetAllPlayerPoliciesCommand_ContainsRequiredInputs() | ||
{ | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(k_AccessModule.GetAllPlayerPoliciesCommand!.Options, Does.Contain(CommonInput.CloudProjectIdOption)); | ||
Assert.That(k_AccessModule.GetAllPlayerPoliciesCommand!.Options, Does.Contain(CommonInput.EnvironmentNameOption)); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void UpsertProjectPolicyCommand_ContainsRequiredInputs() | ||
{ | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(k_AccessModule.UpsertProjectPolicyCommand!.Options, Does.Contain(CommonInput.CloudProjectIdOption)); | ||
Assert.That(k_AccessModule.UpsertProjectPolicyCommand!.Options, Does.Contain(CommonInput.EnvironmentNameOption)); | ||
Assert.That(k_AccessModule.UpsertProjectPolicyCommand!.Arguments, Does.Contain(AccessInput.FilePathArgument)); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void UpsertPlayerPolicyCommand_ContainsRequiredInputs() | ||
{ | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(k_AccessModule.UpsertPlayerPolicyCommand!.Options, Does.Contain(CommonInput.CloudProjectIdOption)); | ||
Assert.That(k_AccessModule.UpsertPlayerPolicyCommand!.Options, Does.Contain(CommonInput.EnvironmentNameOption)); | ||
Assert.That(k_AccessModule.UpsertPlayerPolicyCommand!.Arguments, Does.Contain(AccessInput.PlayerIdArgument)); | ||
Assert.That(k_AccessModule.UpsertPlayerPolicyCommand!.Arguments, Does.Contain(AccessInput.FilePathArgument)); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void DeleteProjectPolicyStatements_ContainsRequiredInputs() | ||
{ | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(k_AccessModule.DeleteProjectPolicyStatementsCommand!.Options, Does.Contain(CommonInput.CloudProjectIdOption)); | ||
Assert.That(k_AccessModule.DeleteProjectPolicyStatementsCommand!.Options, Does.Contain(CommonInput.EnvironmentNameOption)); | ||
Assert.That(k_AccessModule.DeleteProjectPolicyStatementsCommand!.Arguments, Does.Contain(AccessInput.FilePathArgument)); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void DeletePlayerPolicyStatements_ContainsRequiredInputs() | ||
{ | ||
Assert.Multiple(() => | ||
{ | ||
Assert.That(k_AccessModule.DeletePlayerPolicyStatementsCommand!.Options, Does.Contain(CommonInput.CloudProjectIdOption)); | ||
Assert.That(k_AccessModule.DeletePlayerPolicyStatementsCommand!.Options, Does.Contain(CommonInput.EnvironmentNameOption)); | ||
Assert.That(k_AccessModule.DeletePlayerPolicyStatementsCommand!.Arguments, Does.Contain(AccessInput.PlayerIdArgument)); | ||
Assert.That(k_AccessModule.DeletePlayerPolicyStatementsCommand!.Arguments, Does.Contain(AccessInput.FilePathArgument)); | ||
}); | ||
} | ||
|
||
[TestCase(typeof(IProjectPolicyApi))] | ||
[TestCase(typeof(IPlayerPolicyApi))] | ||
[TestCase(typeof(IAccessService))] | ||
public void AccessModuleModuleRegistersServices(Type serviceType) | ||
{ | ||
EndpointHelper.InitializeNetworkTargetEndpoints(new[] | ||
{ | ||
typeof(AccessEndpoints).GetTypeInfo() | ||
}); | ||
var services = new List<ServiceDescriptor>(); | ||
var hostBuilder = TestsHelper.CreateAndSetupMockHostBuilder(services); | ||
hostBuilder.ConfigureServices(AccessModule.RegisterServices); | ||
Assert.That(services.FirstOrDefault(c => c.ServiceType == serviceType), Is.Not.Null); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...i/Unity.Services.Cli.Access.UnitTest/Handlers/DeletePlayerPolicyStatementsHandlerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Moq; | ||
using NUnit.Framework; | ||
using Spectre.Console; | ||
using Unity.Services.Cli.Access.Handlers; | ||
using Unity.Services.Cli.Access.Input; | ||
using Unity.Services.Cli.Access.Service; | ||
using Unity.Services.Cli.Access.UnitTest.Utils; | ||
using Unity.Services.Cli.Common.Console; | ||
using Unity.Services.Cli.Common.Utils; | ||
using Unity.Services.Cli.TestUtils; | ||
using ILogger = Microsoft.Extensions.Logging.ILogger; | ||
|
||
namespace Unity.Services.Cli.Access.UnitTest.Handlers; | ||
|
||
[TestFixture] | ||
public class DeletePlayerPolicyStatementsHandlerTests | ||
{ | ||
readonly Mock<IAccessService> m_MockAccessService = new(); | ||
readonly Mock<ILogger> m_MockLogger = new(); | ||
readonly Mock<IUnityEnvironment> m_MockUnityEnvironment = new(); | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
m_MockAccessService.Reset(); | ||
m_MockLogger.Reset(); | ||
m_MockUnityEnvironment.Reset(); | ||
} | ||
|
||
[Test] | ||
public async Task DeletePlayerPolicyStatementsAsync_CallsLoadingIndicator() | ||
{ | ||
Mock<ILoadingIndicator> mockLoadingIndicator = new Mock<ILoadingIndicator>(); | ||
await DeletePlayerPolicyStatementsHandler.DeletePlayerPolicyStatementsAsync(null!, null!, null!, null!, | ||
mockLoadingIndicator.Object, CancellationToken.None); | ||
mockLoadingIndicator.Verify(ex => ex | ||
.StartLoadingAsync(It.IsAny<string>(), It.IsAny<Func<StatusContext?,Task>>()), Times.Once); | ||
} | ||
|
||
[Test] | ||
public async Task DeletePlayerPolicyStatementsHandler_valid() | ||
{ | ||
AccessInput input = new() | ||
{ | ||
CloudProjectId = TestValues.ValidProjectId, | ||
PlayerId = TestValues.ValidPlayerId, | ||
FilePath = new FileInfo(TestValues.FilePath) | ||
}; | ||
|
||
m_MockUnityEnvironment.Setup(x => x.FetchIdentifierAsync()).ReturnsAsync(TestValues.ValidEnvironmentId); | ||
m_MockAccessService?.Setup(x => | ||
x.DeletePlayerPolicyStatementsAsync(TestValues.ValidProjectId, TestValues.ValidEnvironmentId, TestValues.ValidPlayerId, It.IsAny<FileInfo>(), CancellationToken.None)); | ||
|
||
await DeletePlayerPolicyStatementsHandler.DeletePlayerPolicyStatementsAsync(input, m_MockUnityEnvironment.Object, | ||
m_MockAccessService!.Object, m_MockLogger!.Object, CancellationToken.None); | ||
|
||
m_MockUnityEnvironment.Verify(x => x.FetchIdentifierAsync(), Times.Once); | ||
m_MockAccessService.Verify(x => x.DeletePlayerPolicyStatementsAsync(TestValues.ValidProjectId, TestValues.ValidEnvironmentId, TestValues.ValidPlayerId, It.IsAny<FileInfo>(), CancellationToken.None), Times.Once); | ||
TestsHelper.VerifyLoggerWasCalled(m_MockLogger, LogLevel.Information, expectedTimes: Times.Once); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
.../Unity.Services.Cli.Access.UnitTest/Handlers/DeleteProjectPolicyStatementsHandlerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Moq; | ||
using NUnit.Framework; | ||
using Spectre.Console; | ||
using Unity.Services.Cli.Access.Handlers; | ||
using Unity.Services.Cli.Access.Input; | ||
using Unity.Services.Cli.Access.Service; | ||
using Unity.Services.Cli.Access.UnitTest.Utils; | ||
using Unity.Services.Cli.Common.Console; | ||
using Unity.Services.Cli.Common.Utils; | ||
using Unity.Services.Cli.TestUtils; | ||
using ILogger = Microsoft.Extensions.Logging.ILogger; | ||
|
||
namespace Unity.Services.Cli.Access.UnitTest.Handlers; | ||
|
||
[TestFixture] | ||
public class DeleteProjectPolicyStatementsHandlerTests | ||
{ | ||
readonly Mock<IAccessService> m_MockAccessService = new(); | ||
readonly Mock<ILogger> m_MockLogger = new(); | ||
readonly Mock<IUnityEnvironment> m_MockUnityEnvironment = new(); | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
m_MockAccessService.Reset(); | ||
m_MockLogger.Reset(); | ||
m_MockUnityEnvironment.Reset(); | ||
} | ||
|
||
[Test] | ||
public async Task DeleteProjectPolicyStatementsAsync_CallsLoadingIndicator() | ||
{ | ||
Mock<ILoadingIndicator> mockLoadingIndicator = new Mock<ILoadingIndicator>(); | ||
await DeleteProjectPolicyStatementsHandler.DeleteProjectPolicyStatementsAsync(null!, null!, null!, null!, | ||
mockLoadingIndicator.Object, CancellationToken.None); | ||
mockLoadingIndicator.Verify(ex => ex | ||
.StartLoadingAsync(It.IsAny<string>(), It.IsAny<Func<StatusContext?,Task>>()), Times.Once); | ||
} | ||
|
||
[Test] | ||
public async Task DeleteProjectPolicyStatementsHandler_valid() | ||
{ | ||
AccessInput input = new() | ||
{ | ||
CloudProjectId = TestValues.ValidProjectId, | ||
FilePath = new FileInfo(TestValues.FilePath) | ||
}; | ||
|
||
m_MockUnityEnvironment.Setup(x => x.FetchIdentifierAsync()).ReturnsAsync(TestValues.ValidEnvironmentId); | ||
m_MockAccessService?.Setup(x => | ||
x.DeletePolicyStatementsAsync(TestValues.ValidProjectId, TestValues.ValidEnvironmentId, It.IsAny<FileInfo>(), CancellationToken.None)); | ||
|
||
await DeleteProjectPolicyStatementsHandler.DeleteProjectPolicyStatementsAsync(input, m_MockUnityEnvironment.Object, | ||
m_MockAccessService!.Object, m_MockLogger!.Object, CancellationToken.None); | ||
|
||
m_MockUnityEnvironment.Verify(x => x.FetchIdentifierAsync(), Times.Once); | ||
m_MockAccessService.Verify(x => x.DeletePolicyStatementsAsync(TestValues.ValidProjectId, TestValues.ValidEnvironmentId, It.IsAny<FileInfo>(), CancellationToken.None), Times.Once); | ||
TestsHelper.VerifyLoggerWasCalled(m_MockLogger, LogLevel.Information, expectedTimes: Times.Once); | ||
} | ||
} |
Oops, something went wrong.