public async void GetOneMembership_WhenRoleIsLearner() { var clientResponse = await MembershipClient.GetMembershipAsync(_client, "/ims/membership", Key, Secret, role : Role.Learner); Assert.Equal(HttpStatusCode.OK, clientResponse.StatusCode); Assert.Equal(1, clientResponse.Response.Count); }
public async void GetAllMemberships_WhenGetMembershipAsyncIsCalled() { var clientResponse = await MembershipClient.GetMembershipAsync(_client, "/ims/membership", Key, Secret); Assert.Equal(HttpStatusCode.OK, clientResponse.StatusCode); Assert.NotNull(clientResponse.Response); JsonAssertions.AssertSameObjectJson(new { clientResponse.Response }, "Memberships"); }
public async void GetOneMembershipPage_WhenGetMembershipPageAsyncIsCalled() { var clientResponse = await MembershipClient.GetMembershipPageAsync(_client, "/ims/membership", Key, Secret); Assert.Equal(HttpStatusCode.OK, clientResponse.StatusCode); Assert.NotNull(clientResponse.Response); JsonAssertions.AssertSameObjectJson(clientResponse.Response, "MembershipContainerPage"); }
public async void ReturnNotFound_WhenThereIsAnUnknownContextId() { // Given a working LTI Membership Service endpoint // When I specify an unknown contextId var clientResponse = await MembershipClient.GetMembershipAsync(_client, "/ims/membership/context/context-2", Key, Secret); // Then I get a NotFound response Assert.Equal(HttpStatusCode.NotFound, clientResponse.StatusCode); }
public async void ReturnNotFound_WhenTheSpecifiedPageDoesNotExist() { // Given a working LTI Membership Service endpoint // When I call GetMembershipPageAsync with an invalid page number var clientResponse = await MembershipClient.GetMembershipPageAsync(_client, "/ims/membership/context/context-1?page=3", Key, Secret); // Then I get a NotFound response Assert.Equal(HttpStatusCode.NotFound, clientResponse.StatusCode); }
public async void ReturnNotFound_WhenEndpointDoesNotExist() { // Given a non-existent LTI Membership Service endpoint // When I call GetMembershipPageAsync var clientResponse = await MembershipClient.GetMembershipPageAsync(_client, "/api/nowhere/context/context-1", Key, Secret); // Then I get a NotFound response Assert.Equal(HttpStatusCode.NotFound, clientResponse.StatusCode); }
public async void ReturnNotFound_WhenControllerHasNotImplementedOnGetMembershipAsync() { // Given a working LTI Membership Service endpoint // When I call GetMembershipPageAsync var clientResponse = await MembershipClient.GetMembershipPageAsync(_client, "/api/memberships/context/context-1", Key, Secret); // Then I get a NotFound response Assert.Equal(HttpStatusCode.NotFound, clientResponse.StatusCode); }
public async void ReturnsLearners_WhenRoleFilterIsLearner() { // Given a working LTI Membership Service endpoint // When I call GetMembershipAsync with the Learner role filter var clientResponse = await MembershipClient.GetMembershipAsync(_client, "/ims/membership/context/context-1", Key, Secret, role : ContextRole.Learner); // Then I get an OK response Assert.Equal(HttpStatusCode.OK, clientResponse.StatusCode); // And the response is not null Assert.NotNull(clientResponse.Response); // And there is exactly one membership Assert.Equal(1, clientResponse.Response.Count); }
public async void ReturnAllMemberships() { // Given a working LTI Membership Service endpoint // When I call GetMembershipAsync without any filters var clientResponse = await MembershipClient.GetMembershipAsync(_client, "/ims/membership/context/context-1", Key, Secret); // Then I get an OK response Assert.Equal(HttpStatusCode.OK, clientResponse.StatusCode); // And the response is not null Assert.NotNull(clientResponse.Response); // And the response matches the response in Memberships.json JsonAssertions.AssertSameObjectJson(new { clientResponse.Response }, "Memberships"); }
public async Task ReturnNoMemberships_WhenImageUrlsAreInvalid_AndErrorHandlerIsNull() { // Given a working LTI Membership Service endpoint // When I call GetMembershipAsync without any filters var clientResponse = await MembershipClient.GetMembershipAsync(_client, "/ims/rawmembership/RawMembershipsWithInvalidImageUrl", Key, Secret); // Then I get an OK response Assert.Equal(HttpStatusCode.OK, clientResponse.StatusCode); // And the response is not null Assert.NotNull(clientResponse.Response); // And the response is empty Assert.Equal(0, clientResponse.Response.Count); }
public async Task <IEnumerable <Membership> > GetAllMembers(string membershipUrl, string key, string resourceLinkId) { using (HttpClient httpClient = _httpClientFactory.CreateClient(EdnaExternalHttpHandler.Name)) { ClientResponse <List <Membership> > membershipResponse = await MembershipClient.GetMembershipAsync(httpClient, membershipUrl, key, ToolSecret, resourceLinkId); if (membershipResponse.Exception != null) { _logger.LogError(membershipResponse.Exception, "Failed to fetch LTI1 users."); return(Enumerable.Empty <Membership>()); } return(membershipResponse.Response); } }
public async Task ReturnAllMemberships_WhenImageUrlsAreInvalid_AndErrorHandlerIgnoresErrors() { // Given a working LTI Membership Service endpoint // When I call GetMembershipAsync without any filters var clientResponse = await MembershipClient.GetMembershipAsync ( _client, "/ims/rawmembership/RawMembershipsWithInvalidImageUrl", Key, Secret, // Ignore deserialization errors deserializationErrorHandler : HandleDeserializationError ); // Then I get an OK response Assert.Equal(HttpStatusCode.OK, clientResponse.StatusCode); // And the response is not null Assert.NotNull(clientResponse.Response); // And the response matches the response in Memberships.json JsonAssertions.AssertSameObjectJson(new { clientResponse.Response }, "MembershipsWithNoImages"); }
public async Task ReturnsInstructors_WhenRoleFilterIsInstructorWithNoBaseAddress() { // Given a working LTI Membership Service endpoint // When I call GetMembershipAsync with the Learner role filter var client = _server.CreateClient(); client.BaseAddress = null; var clientResponse = await MembershipClient.GetMembershipAsync(client, "http://localhost/ims/membership/context/context-1", Key, Secret, role : ContextRole.Instructor); // Then I get an OK response Assert.Equal(HttpStatusCode.OK, clientResponse.StatusCode); // And the response is not null Assert.NotNull(clientResponse.Response); // And there is exactly one membership Assert.Equal(1, clientResponse.Response.Count); // And the role is Instructor Assert.Equal(clientResponse.Response[0].Role[0], ContextRole.Instructor); }
public void SetUp() { fixture = SparkTestFixture.Instance; Assert.IsNotNull(fixture); //spark = fixture.spark; spark = fixture.CreateSpark(); Assert.IsNotNull(spark); memberships = spark.Memberships; Assert.IsNotNull(memberships); if (other == null) { other = fixture.CreatUser(); } var room = fixture.CreateRoom("test room"); Assert.IsNotNull(room); roomId = room.Id; }
public void SetUp() { fixture = WebexTestFixture.Instance; Assert.IsNotNull(fixture); //webex = fixture.webex; webex = fixture.CreateWebex(); Assert.IsNotNull(webex); memberships = webex.Memberships; Assert.IsNotNull(memberships); if (other == null) { other = fixture.CreatUser(); } var space = fixture.CreateSpace("test space"); Assert.IsNotNull(space); spaceId = space.Id; }
public async Task ReturnUnauthorized_WhenSecretIsWrong() { var clientResponse = await MembershipClient.GetMembershipPageAsync(_client, "/ims/membership/context/context-1", Key, "notsecret"); Assert.Equal(HttpStatusCode.Unauthorized, clientResponse.StatusCode); }