internal static async Task <string> SignInWithEmailLinkAsync( string email, string oobCode, string tenantId = null) { var rb = new RequestBuilder() { Method = HttpConsts.Post, BaseUri = new Uri(EmailLinkSignInUrl), }; rb.AddParameter(RequestParameterType.Query, "key", IntegrationTestUtils.GetApiKey()); var data = new Dictionary <string, object>() { { "email", email }, { "oobCode", oobCode }, }; if (tenantId != null) { data["tenantId"] = tenantId; } var payload = JsonParser.Serialize(data); var request = rb.CreateRequest(); request.Content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await SendAndDeserialize <VerifyPasswordResponse>(request); return(response.IdToken); }
internal static async Task <string> SignInWithCustomTokenAsync( string customToken, string tenantId = null) { var rb = new RequestBuilder() { Method = HttpConsts.Post, BaseUri = new Uri(VerifyCustomTokenUrl), }; rb.AddParameter(RequestParameterType.Query, "key", IntegrationTestUtils.GetApiKey()); var request = rb.CreateRequest(); var payload = JsonParser.Serialize(new SignInRequest { CustomToken = customToken, TenantId = tenantId, ReturnSecureToken = true, }); request.Content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await SendAndDeserialize <SignInResponse>(request); return(response.IdToken); }
private IEnumerable <ConsumeResult <string, string> > SetupTest(Action <StreamBuilder> builderFunction, TopologyTestDriver.Mode mode = TopologyTestDriver.Mode.SYNC_TASK, int numberPartition = 1) { var config = new StreamConfig <StringSerDes, StringSerDes> { ApplicationId = "test-repartition-processor" }; StreamBuilder builder = new StreamBuilder(); builderFunction(builder); Topology t = builder.Build(); IKafkaSupplier supplier = mode == TopologyTestDriver.Mode.ASYNC_CLUSTER_IN_MEMORY ? new MockKafkaSupplier(numberPartition) : null; using (var driver = new TopologyTestDriver(t.Builder, config, mode, supplier)) { var inputTopic = driver.CreateInputTopic <string, string>("topic"); var outputTopic = driver.CreateOuputTopic <string, string>("output"); inputTopic.PipeInput("test", "test1"); inputTopic.PipeInput("test", "test2"); inputTopic.PipeInput("test", "test3"); var records = IntegrationTestUtils.WaitUntilMinKeyValueRecordsReceived(outputTopic, 3); var recordsMap = records.ToUpdateDictionary(r => r.Message.Key, r => r.Message.Value); Assert.IsNotNull(recordsMap); Assert.AreEqual(1, recordsMap.Count); Assert.AreEqual("test3", recordsMap["test"]); return(records); } }
private static async Task <string> ResetPasswordAsync(ResetPasswordRequest data) { var rb = new Google.Apis.Requests.RequestBuilder() { Method = Google.Apis.Http.HttpConsts.Post, BaseUri = new Uri(ResetPasswordUrl), }; rb.AddParameter(RequestParameterType.Query, "key", IntegrationTestUtils.GetApiKey()); var jsonSerializer = Google.Apis.Json.NewtonsoftJsonSerializer.Instance; var payload = jsonSerializer.Serialize(data); var request = rb.CreateRequest(); request.Content = new StringContent(payload, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); var parsed = jsonSerializer.Deserialize <Dictionary <string, object> >(json); return((string)parsed["email"]); } }
public void RepartitionTestTopologyAsync1() { var config = new StreamConfig <StringSerDes, StringSerDes> { ApplicationId = "test-repartition-processor" }; StreamBuilder builder = new StreamBuilder(); builder .Stream <string, string>("topic") .Map((k, v) => KeyValuePair.Create(k.ToUpper(), v)) .GroupByKey() .Count() .ToStream() .To("output"); Topology t = builder.Build(); using (var driver = new TopologyTestDriver(t, config, TopologyTestDriver.Mode.ASYNC_CLUSTER_IN_MEMORY)) { var inputTopic = driver.CreateInputTopic <string, string>("topic"); var outputTopic = driver.CreateOuputTopic <string, long, StringSerDes, Int64SerDes>("output"); inputTopic.PipeInput("test", "test1"); inputTopic.PipeInput("test", "test2"); inputTopic.PipeInput("test", "test3"); var records = IntegrationTestUtils .WaitUntilMinKeyValueRecordsReceived(outputTopic, 3) .ToUpdateDictionary(r => r.Message.Key, r => r.Message.Value); Assert.IsNotNull(records); Assert.AreEqual(1, records.Count); Assert.AreEqual(3, records["TEST"]); } }
private static async Task <string> SignInWithPasswordAsync(string email, string password) { var rb = new Google.Apis.Requests.RequestBuilder() { Method = Google.Apis.Http.HttpConsts.Post, BaseUri = new Uri(VerifyPasswordUrl), }; rb.AddParameter(RequestParameterType.Query, "key", IntegrationTestUtils.GetApiKey()); var request = rb.CreateRequest(); var jsonSerializer = Google.Apis.Json.NewtonsoftJsonSerializer.Instance; var payload = jsonSerializer.Serialize(new VerifyPasswordRequest { Email = email, Password = password, ReturnSecureToken = true, }); request.Content = new StringContent(payload, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); var parsed = jsonSerializer.Deserialize <VerifyPasswordResponse>(json); return(parsed.IdToken); } }
private IEnumerator SetGoldAction(int i_amount) { yield return(IntegrationTestUtils.SetPlayerCurrencyAndWait(i_amount)); IResourceInventory inventory = (IResourceInventory)PlayerManager.Data; inventory.SetResources(VirtualCurrencies.GOLD, i_amount); }
public GetUsersFixture() { IntegrationTestUtils.EnsureDefaultApp(); this.userBuilder = new TemporaryUserBuilder(FirebaseAuth.DefaultInstance); this.TestUser1 = this.userBuilder.CreateRandomUserAsync().Result; this.TestUser2 = this.userBuilder.CreateRandomUserAsync().Result; this.TestUser3 = this.userBuilder.CreateRandomUserAsync().Result; this.ImportUserUid = this.ImportUserWithProviderAsync().Result; }
public void ReturnsWrongKTableEventWithIntermediateTopicAndTimestampExtractor() { var topo = KStreamWithIntermediateTopicReKeyJoinTopology(new MyTimestampExtractor()); using var driver = new TopologyTestDriver(topo, BuildStreamConfig()); var topic = driver.CreateMultiInputTopic <string, string>(userClicksTopic, userRegionsTopic); var output = driver.CreateOuputTopic <string, string>(outputTopic); AliceChangesRegionsAfterClickingOnWebsite(topic); var items = IntegrationTestUtils.WaitUntilMinKeyValueRecordsReceived(output, 1); Assert.AreEqual(1, items.Count); AssertExtensions.MessageEqual(("alice", "200|click 1 --- 100|asia"), items[0]); }
public TenantFixture() { IntegrationTestUtils.EnsureDefaultApp(); var tenantManager = FirebaseAuth.DefaultInstance.TenantManager; var args = new TenantArgs { DisplayName = "admin-dotnet-tenant", PasswordSignUpAllowed = true, EmailLinkSignInEnabled = true, }; this.Tenant = tenantManager.CreateTenantAsync(args).Result; this.Auth = tenantManager.AuthForTenant(this.Tenant.TenantId); this.TenantId = this.Tenant.TenantId; }
public void ReturnsWrongKTableEventWithExplicitSubTopologyAndTimestampExtractor() { var topo = KStreamWithExplicitReKeyJoinWithExplicitSubTopology(new MyTimestampExtractor()); var config = BuildStreamConfig(); config.MaxTaskIdleMs = 1000; using var driver = new TopologyTestDriver(topo, config, TopologyTestDriver.Mode.ASYNC_CLUSTER_IN_MEMORY); var topic = driver.CreateMultiInputTopic <string, string>(userClicksTopic, userRegionsTopic); var output = driver.CreateOuputTopic <string, string>(outputTopic); AliceChangesRegionsAfterClickingOnWebsite(topic); var items = IntegrationTestUtils.WaitUntilMinKeyValueRecordsReceived(output, 1); Assert.AreEqual(1, items.Count); AssertExtensions.MessageEqual(("alice", "200|click 1 --- 100|asia"), items[0]); }
public OidcProviderConfigFixture() { IntegrationTestUtils.EnsureDefaultApp(); var providerId = $"oidc.{GetRandomIdentifier()}"; var args = new OidcProviderConfigArgs() { ProviderId = providerId, DisplayName = "OIDC_DISPLAY_NAME", Enabled = true, ClientId = "OIDC_CLIENT_ID", Issuer = "https://oidc.com/issuer", }; this.ProviderConfig = FirebaseAuth.DefaultInstance .CreateProviderConfigAsync(args) .Result; this.ProviderId = providerId; }
public void RepartitionTestJoinTopology() { var config = new StreamConfig <StringSerDes, StringSerDes> { ApplicationId = "test-repartition-processor" }; var supplier = new MockKafkaSupplier(10); StreamBuilder builder = new StreamBuilder(); IKStream <string, string> stream1 = builder .Stream <string, string>("topic") .Map((k, v) => KeyValuePair.Create(k.ToUpper(), v)); IKStream <string, string> stream2 = builder.Stream <string, string>("topic2"); stream1.Join(stream2, (v1, v2) => $"{v1}-{v2}", JoinWindowOptions.Of(TimeSpan.FromMinutes(1)), StreamJoinProps.As <string, string, string>("join-store")) .To("output"); Topology t = builder.Build(); using (var driver = new TopologyTestDriver(t.Builder, config, TopologyTestDriver.Mode.ASYNC_CLUSTER_IN_MEMORY, supplier)) { var inputTopic = driver.CreateInputTopic <string, string>("topic"); var inputTopic2 = driver.CreateInputTopic <string, string>("topic2"); var outputTopic = driver.CreateOuputTopic <string, string>("output"); inputTopic.PipeInput("test", "coucou"); inputTopic2.PipeInput("TEST", "sylvain"); inputTopic2.PipeInput("TEST2", "antoine"); inputTopic.PipeInput("test2", "test"); var records = IntegrationTestUtils .WaitUntilMinKeyValueRecordsReceived(outputTopic, 2) .ToUpdateDictionary(r => r.Message.Key, r => r.Message.Value); Assert.IsNotNull(records); Assert.AreEqual(2, records.Count); Assert.AreEqual("coucou-sylvain", records["TEST"]); Assert.AreEqual("test-antoine", records["TEST2"]); } }
internal static async Task <string> ResetPasswordAsync(ResetPasswordRequest data) { var rb = new RequestBuilder() { Method = HttpConsts.Post, BaseUri = new Uri(ResetPasswordUrl), }; rb.AddParameter(RequestParameterType.Query, "key", IntegrationTestUtils.GetApiKey()); var payload = JsonParser.Serialize(data); var request = rb.CreateRequest(); request.Content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await SendAndDeserialize <Dictionary <string, object> >(request); return((string)response["email"]); }
public void RepartitionInternalTopicOnCascace() { var config = new StreamConfig <StringSerDes, StringSerDes> { ApplicationId = "test-repartition-processor-on-cascade" }; StreamBuilder builder = new StreamBuilder(); var table = builder.Table <string, string>("input-table"); builder .Stream <string, string>("topic") .SelectKey((k, v) => v.ToUpper()) .Join(table, (v, t) => $"{v}:{t}") .To("output"); Topology t = builder.Build(); MockKafkaSupplier supplier = new MockKafkaSupplier(4); using (var driver = new TopologyTestDriver(t.Builder, config, TopologyTestDriver.Mode.ASYNC_CLUSTER_IN_MEMORY, supplier)) { var inputTopic = driver.CreateInputTopic <string, string>("topic"); var inputTableTopic = driver.CreateInputTopic <string, string>("input-table"); var outputTopic = driver.CreateOuputTopic <string, string>("output"); inputTableTopic.PipeInput("PRODUCT1", "P1"); inputTableTopic.PipeInput("PRODUCT2", "P2"); inputTopic.PipeInput("test", "product1"); inputTopic.PipeInput("test", "product2"); var records = IntegrationTestUtils .WaitUntilMinKeyValueRecordsReceived(outputTopic, 2) .ToUpdateDictionary(r => r.Message.Key, r => r.Message.Value); Assert.IsNotNull(records); Assert.AreEqual(2, records.Count); Assert.AreEqual("product2:P2", records["PRODUCT2"]); Assert.AreEqual("product1:P1", records["PRODUCT1"]); } }
public void JoinGlobakKTable() { var source = new CancellationTokenSource(); var config = new StreamConfig <StringSerDes, StringSerDes>(); config.ApplicationId = "test-config"; config.PollMs = 10; var topicConfiguration = config.Clone(); topicConfiguration.ApplicationId = $"test-driver-{config.ApplicationId}"; var builder = new StreamBuilder(); var globalktable = builder.GlobalTable("test", InMemory <string, string> .As("global-store")); builder.Stream <string, string>("source") .Join(globalktable, (k, v) => k, (v1, v2) => $"{v1}-{v2}") .To("sink"); var driver = new ClusterInMemoryTopologyDriver("client", builder.Build().Builder, config, topicConfiguration, TimeSpan.FromSeconds(1), source.Token); driver.StartDriver(); var inputTest = driver.CreateInputTopic("test", new StringSerDes(), new StringSerDes()); var inputSource = driver.CreateInputTopic("source", new StringSerDes(), new StringSerDes()); var output = driver.CreateOutputTopic("sink", TimeSpan.FromSeconds(1), new StringSerDes(), new StringSerDes()); inputTest.PipeInput("coucou", "Sylvain"); Thread.Sleep(100); inputSource.PipeInput("coucou", "Coucou"); Thread.Sleep(300); var records = IntegrationTestUtils.WaitUntilMinKeyValueRecordsReceived(output, 1); Assert.AreEqual(1, records.Count); Assert.AreEqual("Coucou-Sylvain", records.First().Message.Value); source.Cancel(); driver.Dispose(); }
private void RunSuiteTest(IDictionary <string, object> suite, KeyValuePair <string, object> testEntry) { var test = (IDictionary <string, object>)testEntry.Value; this.output.WriteLine($"Test: {testEntry.Key} - {test["description"]}"); var config = (IDictionary <string, object>)(test.ContainsKey("conf") ? test["conf"] : suite["conf"]); var artifact = (string)(test.ContainsKey("artifact") ? test["artifact"] : suite["artifact"]); var clientConfig = this.GetTargetClientConfig(config, artifact); VisitorProvider.Initialize(clientConfig.OrganizationId); var mockTargetService = new Mock <ITargetService>(); var mockGeo = IntegrationTestUtils.GetMockGeo(test); IntegrationTestUtils.SetupMockDateTime(test); var decisioningService = new OnDeviceDecisioningService(clientConfig, mockTargetService.Object, mockGeo?.Object); var targetRequest = GetTargetDeliveryRequest(test); var expectedResponseObject = test.ContainsKey("output") ? test["output"] : null; var expectedNotificationObject = test.ContainsKey("notificationOutput") ? test["notificationOutput"] : null; var response = decisioningService.ExecuteRequest(targetRequest); if (expectedResponseObject != null) { var expectedResponse = IntegrationTestUtils.ConvertExpectedResponse(expectedResponseObject); _ = response.Response.Should().BeEquivalentTo(expectedResponse, IntegrationTestUtils.RootResponseEquivalenceOptions); } if (expectedNotificationObject != null) { var expectedNotificationRequestObject = ((IDictionary <string, object>)expectedNotificationObject)["request"]; var expectedNotification = SerializationUtils.ConvertObject <DeliveryRequest>(expectedNotificationRequestObject); Thread.Sleep(500); var notificationRequest = ((TargetDeliveryRequest)mockTargetService.Invocations.Last().Arguments.First()).DeliveryRequest; _ = notificationRequest.Should().BeEquivalentTo(expectedNotification, IntegrationTestUtils.RootRequestEquivalenceOptions); } TimeProvider.ResetToDefault(); }
public SamlProviderConfigFixture() { IntegrationTestUtils.EnsureDefaultApp(); var providerId = $"saml.{GetRandomIdentifier()}"; var args = new SamlProviderConfigArgs() { ProviderId = providerId, DisplayName = "SAML_DISPLAY_NAME", Enabled = true, IdpEntityId = "IDP_ENTITY_ID", SsoUrl = "https://example.com/login", X509Certificates = new List <string> { X509Certificates[0] }, RpEntityId = "RP_ENTITY_ID", CallbackUrl = "https://projectId.firebaseapp.com/__/auth/handler", }; this.ProviderConfig = FirebaseAuth.DefaultInstance .CreateProviderConfigAsync(args) .Result; this.ProviderId = providerId; }
public Fixture() { IntegrationTestUtils.EnsureDefaultApp(); this.UserBuilder = new TemporaryUserBuilder(FirebaseAuth.DefaultInstance); }
public TemporaryUserBuilder() { IntegrationTestUtils.EnsureDefaultApp(); }
static Fixture() { IntegrationTestUtils.EnsureDefaultApp(); }