public void ListTenantsOptions(TestConfig config) { var handler = new MockMessageHandler() { Response = ListTenantsResponses, }; var auth = config.CreateFirebaseAuth(handler); var tenants = new List <Tenant>(); var customOptions = new ListTenantsOptions() { PageSize = 3, PageToken = "custom-token", }; var pagedEnumerable = auth.TenantManager.ListTenantsAsync(customOptions); foreach (var tenant in pagedEnumerable.ToEnumerable()) { tenants.Add(tenant); } Assert.Equal(5, tenants.Count); Assert.All(tenants, AssertTenant); Assert.Equal(2, handler.Requests.Count); config.AssertRequest("tenants?pageSize=3&pageToken=custom-token", handler.Requests[0]); config.AssertRequest("tenants?pageSize=3&pageToken=token", handler.Requests[1]); }
public async Task ListTenantsAsRawResponses(TestConfig config) { var handler = new MockMessageHandler() { Response = ListTenantsResponses, }; var auth = config.CreateFirebaseAuth(handler); var tenants = new List <Tenant>(); var tokens = new List <string>(); var pagedEnumerable = auth.TenantManager.ListTenantsAsync(null); var responses = pagedEnumerable.AsRawResponses().GetAsyncEnumerator(); while (await responses.MoveNextAsync()) { tenants.AddRange(responses.Current.Tenants); tokens.Add(responses.Current.NextPageToken); Assert.Equal(tokens.Count, handler.Requests.Count); } Assert.Equal(new List <string>() { "token", null }, tokens); Assert.Equal(5, tenants.Count); Assert.All(tenants, AssertTenant); Assert.Equal(2, handler.Requests.Count); config.AssertRequest("tenants?pageSize=100", handler.Requests[0]); config.AssertRequest("tenants?pageSize=100&pageToken=token", handler.Requests[1]); }
public async Task UpdateTenantMinimal(TestConfig config) { var handler = new MockMessageHandler() { Response = TenantResponse, }; var auth = config.CreateFirebaseAuth(handler); var args = new TenantArgs() { DisplayName = "Test Tenant", }; var provider = await auth.TenantManager.UpdateTenantAsync("tenant1", args); AssertTenant(provider); Assert.Equal(1, handler.Requests.Count); var request = handler.Requests[0]; Assert.Equal(HttpUtils.Patch, request.Method); config.AssertRequest("tenants/tenant1?updateMask=displayName", request); var body = NewtonsoftJsonSerializer.Instance.Deserialize <JObject>( handler.LastRequestBody); Assert.Single(body); Assert.Equal("Test Tenant", body["displayName"]); }
public async Task UpdateTenant(TestConfig config) { var handler = new MockMessageHandler() { Response = TenantResponse, }; var auth = config.CreateFirebaseAuth(handler); var args = new TenantArgs() { DisplayName = "Test Tenant", PasswordSignUpAllowed = true, EmailLinkSignInEnabled = true, }; var provider = await auth.TenantManager.UpdateTenantAsync("tenant1", args); AssertTenant(provider); Assert.Equal(1, handler.Requests.Count); var request = handler.Requests[0]; Assert.Equal(HttpUtils.Patch, request.Method); var mask = "allowPasswordSignup,displayName,enableEmailLinkSignin"; config.AssertRequest($"tenants/tenant1?updateMask={mask}", request); var body = NewtonsoftJsonSerializer.Instance.Deserialize <JObject>( handler.LastRequestBody); Assert.Equal(3, body.Count); Assert.Equal("Test Tenant", body["displayName"]); Assert.True((bool)body["allowPasswordSignup"]); Assert.True((bool)body["enableEmailLinkSignin"]); }
public async Task ListTenantsByPages(TestConfig config) { var handler = new MockMessageHandler() { Response = ListTenantsResponses, }; var auth = config.CreateFirebaseAuth(handler); var tenants = new List <Tenant>(); // Read page 1. var pagedEnumerable = auth.TenantManager.ListTenantsAsync(null); var tenantsPage = await pagedEnumerable.ReadPageAsync(3); Assert.Equal(3, tenantsPage.Count()); Assert.Equal("token", tenantsPage.NextPageToken); Assert.Single(handler.Requests); config.AssertRequest("tenants?pageSize=3", handler.Requests[0]); tenants.AddRange(tenantsPage); // Read page 2. pagedEnumerable = auth.TenantManager.ListTenantsAsync(new ListTenantsOptions() { PageToken = tenantsPage.NextPageToken, }); tenantsPage = await pagedEnumerable.ReadPageAsync(3); Assert.Equal(2, tenantsPage.Count()); Assert.Null(tenantsPage.NextPageToken); Assert.Equal(2, handler.Requests.Count); config.AssertRequest("tenants?pageSize=3&pageToken=token", handler.Requests[1]); tenants.AddRange(tenantsPage); Assert.Equal(5, tenants.Count); Assert.All(tenants, AssertTenant); }
public async Task ListTenants(TestConfig config) { var handler = new MockMessageHandler() { Response = ListTenantsResponses, }; var auth = config.CreateFirebaseAuth(handler); var tenants = new List <Tenant>(); var pagedEnumerable = auth.TenantManager.ListTenantsAsync(null); var enumerator = pagedEnumerable.GetAsyncEnumerator(); while (await enumerator.MoveNextAsync()) { tenants.Add(enumerator.Current); } Assert.Equal(5, tenants.Count); Assert.All(tenants, AssertTenant); Assert.Equal(2, handler.Requests.Count); config.AssertRequest("tenants?pageSize=100", handler.Requests[0]); config.AssertRequest("tenants?pageSize=100&pageToken=token", handler.Requests[1]); }
public async Task DeleteTenant(TestConfig config) { var handler = new MockMessageHandler() { Response = TenantResponse, }; var auth = config.CreateFirebaseAuth(handler); await auth.TenantManager.DeleteTenantAsync("tenant1"); Assert.Equal(1, handler.Requests.Count); var request = handler.Requests[0]; Assert.Equal(HttpMethod.Delete, request.Method); config.AssertRequest("tenants/tenant1", request); }
public async Task CreateTenantMinimal(TestConfig config) { var handler = new MockMessageHandler() { Response = TenantResponse, }; var auth = config.CreateFirebaseAuth(handler); var provider = await auth.TenantManager.CreateTenantAsync(new TenantArgs()); AssertTenant(provider); Assert.Equal(1, handler.Requests.Count); var request = handler.Requests[0]; Assert.Equal(HttpMethod.Post, request.Method); config.AssertRequest("tenants", request); var body = NewtonsoftJsonSerializer.Instance.Deserialize <JObject>( handler.LastRequestBody); Assert.Empty(body); }