public async Task BasicLoginTest() { IAuthentication auth = new UnattendedAuthentication(_message, TestContext.Parameters["ClientId"], TestContext.Parameters["ClientSecret"], TestContext.Parameters["Username"], TestContext.Parameters["Password"]); await auth.Authenticate(); //Confirm sustem believes authenticated Assert.IsTrue(auth.Authenticated, "Not authenticated"); }
public async Task GetAuthenticatedClientTest() { IAuthentication auth = new UnattendedAuthentication(_message, TestContext.Parameters["ClientId"], TestContext.Parameters["ClientSecret"], TestContext.Parameters["Username"], TestContext.Parameters["Password"]); await auth.Authenticate(); HttpClient client = auth.GetAuthenticatedClient(); Assert.Multiple(() => { StringAssert.AreEqualIgnoringCase("Bearer", client.DefaultRequestHeaders.Authorization.Scheme, "Bearer token not set"); Assert.IsFalse(String.IsNullOrEmpty(client.DefaultRequestHeaders.Authorization.Parameter), "No auth parameter set"); }); }
public async Task GetUserTest() { IAuthentication auth = new UnattendedAuthentication(_message, TestContext.Parameters["ClientId"], TestContext.Parameters["ClientSecret"], TestContext.Parameters["Username"], TestContext.Parameters["Password"]); await auth.Authenticate(); //Verify by retrieving the user info User profile = await auth.GetUserProfile(); Assert.Multiple(() => { Assert.IsFalse(String.IsNullOrEmpty(profile.Name), "Empty name"); Assert.IsFalse(String.IsNullOrEmpty(profile.UserId), "Empty User Id"); Assert.IsFalse(String.IsNullOrEmpty(profile.Username), "Empty username"); }); }