public void Get_401_When_accessing_Secure_using_RestClient_PUT_without_Authorization() { var client = CreateNewRestClientAsync(); if (client == null) { return; } SecureResponse response = null; var wasError = false; client.PutAsync <SecureResponse>(ServiceClientBaseUri + "secure", new Secure(), r => response = r, (r, ex) => wasError = Assert401(r, ex)); Thread.Sleep(1000); Assert.That(wasError, Is.True, "Should throw WebServiceException.StatusCode == 401"); Assert.IsNull(response); }
public void Can_login_with_Basic_auth_to_access_Secure_service_using_RestClientAsync() { var format = GetFormat(); if (format == null) { return; } var client = CreateNewRestClientAsync(); client.SetCredentials(AllowedUser, AllowedPass); SecureResponse response = null; client.GetAsync <SecureResponse>(ServiceClientBaseUri + "secure", r => response = r, FailOnAsyncError); Thread.Sleep(2000); Assert.That(response.Result, Is.EqualTo("Confidential")); }