// public TestWriteOutputPipelineStage OutputStage {get; set;} //will we even need to deal with this in tests? public ITProgram(ITestOutputHelper outputter, Auth0InMemoryStore initialStore = null) { OutputHelper = outputter; StandardOutput = new TestOutputHelperTextWriter(outputter); StandardError = new TestOutputHelperTextWriter(outputter); TokenFactory = new TestTokenFactory { Token = "TestToken" }; OverridesSource = new TestOverridesSource(); TemplateSource = new TestTemplateSource(); Store = initialStore ?? new Auth0InMemoryStore(); //Create a spy wrapping a TestManagementConnection so we can use fakeiteasy-syntax for verifying interactions. RealManagementConnection = new TestManagementConnection(outputter, Store, ApiCalls.AllApiCalls); var fakeManagementConnection = A.Fake <IManagementConnection>(o => o.Wrapping(RealManagementConnection)); A.CallTo(fakeManagementConnection).CallsWrappedMethod(); FakeManagementConnection = fakeManagementConnection; }
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 TestManagementConnection(ITestOutputHelper output, Auth0InMemoryStore store, IList <ApiCall> apiCalls) { _output = output ?? throw new ArgumentNullException(nameof(output)); _store = store; _apiCalls = apiCalls; }