public async Task TestClientWouldBeCreateIfNotForDryRunFlag()
        {
            var program = new ITProgram(_outputHelper);

            await program.Run(new[]
            {
                "process",
                "-v",
                "-out", _testDataPaths.OutputPath(),
                "-t", _testDataPaths.TemplatesPath(),
                "-o", _testDataPaths.OverridesPath("overrides.json"),
                "-d"
            });

            //GET all clients
            A.CallTo(
                () => program.FakeManagementConnection.GetAsync <IPagedList <Client> >(
                    A <Uri> .That.Matches(x => x.ToString().Contains($"https://{_envVars.Domain}/api/v2/clients")),
                    A <Dictionary <string, string> > .That.IsAuthorized(program),
                    A <JsonConverter[]> ._))
            .MustHaveHappened();

            //POST (create) a client - should NOT happen due to -d dry run
            A.CallTo(
                () => program.FakeManagementConnection.SendAsync <Client>(
                    HttpMethod.Post,
                    A <Uri> .That.Matches(x => x.ToString().Contains($"https://{_envVars.Domain}/api/v2/clients")),
                    A <object> ._,
                    A <Dictionary <string, string> > ._,
                    A <IList <FileUploadParameter> > ._))
            .MustNotHaveHappened();
        }
Exemplo n.º 2
0
        public void TestRootHelpArgWritesHelpOutput()
        {
            var program = new ITProgram(_outputter);

            program.Run(new string[] { "--help" });

            program.StandardOutput.AllOutput.ShouldContain("Show version information");
            program.StandardOutput.AllOutput.ShouldContain("banjo [command] [options]");
            program.StandardOutput.AllOutput.ShouldContain("process");
        }
Exemplo n.º 3
0
        public void TestProcessHelpArgWritesHelpOutput()
        {
            var program = new ITProgram(_outputter);

            program.Run(new string[] { "process", "--help" });

            var allStandard = program.StandardOutput.AllOutput;

            allStandard.ShouldContain("Usage:");
            allStandard.ShouldContain("--help");
            allStandard.ShouldContain("--override");
            allStandard.ShouldContain("--dry-run");
        }
        public async Task TestClientWouldBeUpdated()
        {
            var initialClient = new Client
            {
                Name     = ExpectedClientName,
                ClientId = Guid.NewGuid().ToString()
            };

            var initialStoreState = new Auth0InMemoryStore {
                Clients = { initialClient }
            };
            var program = new ITProgram(_outputHelper, initialStoreState);

            await program.Run(new[]
            {
                "process",
                "-v",
                "-out", _testDataPaths.OutputPath(),
                "-t", _testDataPaths.TemplatesPath(),
                "-o", _testDataPaths.OverridesPath("overrides.json")
            });

            //GET all clients
            A.CallTo(
                () => program.FakeManagementConnection.GetAsync <IPagedList <Client> >(
                    A <Uri> .That.Matches(x => x.ToString().Contains($"https://{_envVars.Domain}/api/v2/clients")),
                    A <Dictionary <string, string> > .That.IsAuthorized(program),
                    A <JsonConverter[]> ._))
            .MustHaveHappened();

            //PATCH (update) a specific client
            A.CallTo(
                () => program.FakeManagementConnection.SendAsync <Client>(
                    HttpMethod.Patch,     //Patch == Update
                    A <Uri> .That.Matches(x => x.ToString().Contains($"https://{_envVars.Domain}/api/v2/clients/{initialClient.ClientId}")),
                    A <object> .That.Matches(x => (x as ClientUpdateRequest).Name == ExpectedClientName),
                    A <Dictionary <string, string> > .That.IsAuthorized(program),
                    A <IList <FileUploadParameter> > ._))
            .MustHaveHappened();
        }
        public async Task TestClientWouldBeCreatedWithoutOverriddenName()
        {
            var program = new ITProgram(_outputHelper);

            await program.Run(new[]
            {
                "process",
                "-v",
                "-out", _testDataPaths.OutputPath(),
                "-t", _testDataPaths.TemplatesPath()
                //no overrides specified
            });

            A.CallTo(
                () => program.FakeManagementConnection.SendAsync <Client>(
                    HttpMethod.Post,
                    A <Uri> .That.Matches(x => x.ToString().Contains($"https://{_envVars.Domain}/api/v2/clients")),
                    A <object> .That.Matches(x => (x as ClientCreateRequest).Name == "HerpaDerpaClientName"),
                    A <Dictionary <string, string> > .That.IsAuthorized(program),
                    A <IList <FileUploadParameter> > ._))
            .MustHaveHappened();
        }
 public static T IsAuthorized <T>(this IArgumentConstraintManager <T> manager, ITProgram program) where T : IEnumerable
 {
     return(manager.Contains(KeyValuePair.Create("Authorization", $"Bearer {program.TokenFactory.Token}")));
 }