void AddTokenEndpoint() { var tokenBody = new JObject { ["access_token"] = GetAccessToken(), ["id_token"] = GetIdToken() }; server .Post("/cpaas/auth/v1/token") .Responds(tokenBody.ToString()); }
public void CanDeliverSlackMessageWithCorrectButton() { FluentSimulator slackSimulator = new FluentSimulator("http://localhost:8081/"); string request_url_path = "/actions"; slackSimulator.Post(request_url_path).Responds(""); slackSimulator.Start(); var started = false; var spyToggleWorkshopAttendance = new SpyToggleWorkshopAttendance(); var spyGetWorkshop = new StubGetWorkshop(); spyGetWorkshop.attendees.Add("Bing"); var deliveryMechanism = new DeliveryMechanism(spyToggleWorkshopAttendance, spyGetWorkshop, "5054"); var thread = new Thread(() => { deliveryMechanism.Run(() => { started = true; }); }); thread.Start(); SpinWait.SpinUntil(() => started); SlackButtonPayload payload = new SlackButtonPayload() { User = new User() { Name = "Bing", UserID = "123" }, Actions = new Actions[] { new Actions() { Value = "record3" } }, ResponseURL = "http://localhost:8081/actions" }; string firstjson = JsonConvert.SerializeObject(payload); var encoded = HttpUtility.UrlEncode(firstjson); var fakeSlackWebClient = new WebClient(); fakeSlackWebClient.UploadString("http://localhost:5054/attend", "POST", "payload=" + encoded); var requestReceivedBySlack = slackSimulator.ReceivedRequests; Assert.AreEqual("application/json", requestReceivedBySlack[0].ContentType); Assert.IsTrue(requestReceivedBySlack[0].RequestBody.Contains("Unattend")); slackSimulator.Stop(); }
public void SetUp() { _classUnderTest = new GovNotifyNotificationsGateway(); _govNotifyUrl = Environment.GetEnvironmentVariable("GOV_NOTIFY_URL"); _govNotifyApiKey = Environment.GetEnvironmentVariable("GOV_NOTIFY_API_KEY"); SetupEnvironmentVariables("http://localhost:3000/", "cafe"); _simulator = new FluentSimulator("http://localhost:3000/"); _simulator.Post("/v2/notifications/email").Responds("{}"); _simulator.Start(); }
public void CanUseCustomSerializer() { Sim.Stop(); Sim = new FluentSimulator(BaseAddress, new JsonSerializerSettings { Converters = { new StringEnumConverter() } }); Sim.Start(); Sim.Post("/test") .Responds(new TestEnumClass()); MakePostRequest("/test", "").Content.ShouldBe(@"{""TestEnumField"":""V2""}"); }
public async Task ItUsesTheGovNotifyUrlEnvironmentVariable(string baseUrl) { SetupEnvironmentVariables(baseUrl, "cafe"); var simulator = new FluentSimulator(baseUrl); simulator.Start(); simulator.Post("/v2/notifications/email").Responds("{}"); await _classUnderTest.SendOneTimeLinkAsync(StubNotification(), CancellationToken.None); simulator.ReceivedRequests[0].Url.Should().Be($"{baseUrl}v2/notifications/email"); simulator.Stop(); }
public void FilterTest() { _simulator.Post("/api/filter").Responds("His SSN was {{{REDACTED-ssn}}}.").WithCode(200); PhilterClient philterClient = new PhilterClient(GetClient()); string filteredText = philterClient.Filter("His SSN was 123-45-6789.", "context", "default"); Assert.AreEqual("His SSN was {{{REDACTED-ssn}}}.", filteredText); }
public void CanGetPreviousBodyWithCustomSerializer() { Sim.Stop(); Sim = new FluentSimulator(BaseAddress, new JsonSerializerSettings { Converters = { new AllFieldsReplacementConverter() } }); Sim.Start(); Sim.Post("/test"); MakePostRequest("/test", @"{""TestField"":""original""}"); Sim.ReceivedRequests[0].BodyAs <TestObject>().TestField.ShouldBe("REPLACEMENT"); }
private static void HandleSetUp() { _slackApi = new FluentSimulator(SlackApiAddress); _slackGateway = new SlackGateway(SlackApiAddress, "xxxx-xxxxxxxxx-xxxx"); _sendReminder = new SendReminder(_slackGateway); var slackGetUsersResponse = File.ReadAllText( Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "../../../ApiEndpointResponse/SlackUsersResponse.json" ) ); _slackApi.Get("/" + SlackApiUsersPath).Responds(slackGetUsersResponse); _slackApi.Post("/" + SlackApiPostMessagePath).Responds(new { ok = true }); _slackApi.Start(); }
public void Setup() { Environment.SetEnvironmentVariable("GOV_NOTIFY_URL", GovNotifyHost); Environment.SetEnvironmentVariable("GOV_NOTIFY_API_KEY", GovNotifyApiKey); _govNotifySimulator = new FluentSimulator(GovNotifyHost); _govNotifySimulator.Start(); _govNotifySimulator.Post("/v2/notifications/email").Responds("{}"); var assetRegister = new AssetRegister(); var importUseCase = assetRegister.Get <IImportAssetsUseCase>(); var textSplitter = assetRegister.Get <ITextSplitter>(); var getAssetRegisterVersionUseCase = assetRegister.Get <IGetAssetRegisterVersionsUseCase>(); var assetRegisterUploadNotifier = assetRegister.Get <IAssetRegisterUploadProcessedNotifier>(); var backgroundProcessor = assetRegister.Get <IBackgroundProcessor>(); _assetRegisterContext = assetRegister.Get <AssetRegisterContext>(); _classUnderTest = new AssetRegisterVersionController(getAssetRegisterVersionUseCase, importUseCase, textSplitter, assetRegisterUploadNotifier, backgroundProcessor); }
private async Task <NotifyRequest> RequestAccessToApplication() { var simulator = new FluentSimulator("http://*****:*****@example.com", Url = "http://meow.cat/" }; await _authenticateUser.ExecuteAsync(request, CancellationToken.None); simulator.Stop(); NotifyRequest notifyRequest = simulator.ReceivedRequests[0].BodyAs <NotifyRequest>(); return(notifyRequest); }
public void RespondWithOk() { _simulator.Post("/" + PostMessageApiPath).Responds(new { ok = true }); }