public async Task GivenKnownUser_WhenRetrievingUserDetails_ThenReturnsUserDetails() { StateUnderTestBuilder builder = new StateUnderTestBuilder(_client); var context = await builder.WithUser(false, "someName", $"{Guid.NewGuid()}") .WithKey("some key", "someName") .Build(); var response = await _client.GetAsync("/api/users"); var user = await response.Content.ReadAsAsync <User>(); using (new AssertionScope()) { user.Tenants.Count.Should().Be(1); user.Tenants[0].Name.Should().Be("someName"); } }
public async Task GivenDuplicateKeyNameForTenant_WhenGereatingKey_ThenReturns400() { StateUnderTestBuilder builder = new StateUnderTestBuilder(_client); var context = await builder.WithUser(true, "anyTenant", $"{Guid.NewGuid()}") .Build(); await GenerateKey("Some key", "someName"); var response = await _client.PostAsJsonAsync("/api/keys", new KeyRequest { Name = "Some key", Tenant = "someName" }); Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); }
public async Task GivenUserEnrolled_WhenEnrollingUser_ThenReturnsBadRequest() { StateUnderTestBuilder builder = new StateUnderTestBuilder(_client); var username = $"{Guid.NewGuid()}"; var context = await builder.WithUser(true, "anyTenant", username) .Build(); var response = await _client.PostAsJsonAsync("/api/users", new EnrolUserRequest { TenantName = "another tenant", OptInToMarketing = true, Username = username }); Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); }
public async Task GivenKnownTenant_WhenRetrievingUserDetails_ThenReturnsTenantDetails() { StateUnderTestBuilder builder = new StateUnderTestBuilder(_client); var username = $"{Guid.NewGuid()}"; var tenantName = "someName"; var context = await builder.WithUser(false, tenantName, username) .WithKey("some key", tenantName) .Build(); var response = await _client.GetAsync($"/api/tenants?name=someName"); var tenants = await response.Content.ReadAsAsync <TenantOverview>(); using (new AssertionScope()) { tenants.Projects.Should().BeEmpty(); tenants.Name.Should().Be(tenantName); } }
public async Task GivenKnownUser_WhenGeneratingKeyForTenant_ThenGeneratesKeyForTenant() { StateUnderTestBuilder builder = new StateUnderTestBuilder(_client); var context = await builder.WithUser(true, "anyTenant", $"{Guid.NewGuid()}") .Build(); var expected = "Some key"; var response = await _client.PostAsJsonAsync("/api/keys", new KeyRequest { Name = expected, Tenant = "someName" }); var key = await response.Content.ReadAsAsync <KeyResponse>(); Assert.That(key.Name, Is.EqualTo(expected)); Assert.That(key.Value, Is.Not.EqualTo(Guid.Empty)); }