public void TestGetResources() { RestResponse response = _restClient.SendSync(RestRequest.GetRequestForResources(TestCredentials.API_VERSION)); CheckResponse(response, HttpStatusCode.OK, false); CheckKeys(response.AsJObject, "sobjects", "search", "recent"); }
public async Task TestGetResourcesWithUnAuthenticatedClient() { RestResponse response = await _unauthenticatedRestClient.SendAsync(RestRequest.GetRequestForResources(TestCredentials.API_VERSION)); Assert.AreEqual(response.StatusCode.ToString().ToLower(), HttpStatusCode.Unauthorized.ToString().ToLower()); }
public async Task TestGetResources() { var response = await _restClient.SendAsync(RestRequest.GetRequestForResources(new TestCredentials().ApiVersion)); CheckResponse(response, HttpStatusCode.OK, false); CheckKeys(response.AsJObject, "sobjects", "search", "recent"); }
public void TestCallWithBadAuthToken() { RestClient unauthenticatedRestClient = new RestClient(TestCredentials.INSTANCE_SERVER, BAD_TOKEN, null); RestResponse response = unauthenticatedRestClient.SendSync(RestRequest.GetRequestForResources(TestCredentials.API_VERSION)); Assert.IsFalse(response.Success, "Success not expected"); Assert.IsNotNull(response.Error, "Expected error"); Assert.AreEqual(HttpStatusCode.Unauthorized, response.StatusCode, "Expected 401"); }
public void TestGetRequestForResources() { RestRequest request = RestRequest.GetRequestForResources(TEST_API_VERSION); Assert.AreEqual(HttpMethod.Get, request.Method, "Wrong method"); Assert.AreEqual(ContentTypeValues.None, request.ContentType, "Wrong content type"); Assert.AreEqual("/services/data/" + TEST_API_VERSION + "/", request.Path, "Wrong path"); Assert.IsNull(request.RequestBody, "Wrong request body"); Assert.AreEqual(request.AdditionalHeaders.Count, 0); }
public void TestGetRequestForResources() { RestRequest request = RestRequest.GetRequestForResources(TEST_API_VERSION); Assert.AreEqual(RestMethod.GET, request.Method, "Wrong method"); Assert.AreEqual(ContentType.NONE, request.ContentType, "Wrong content type"); Assert.AreEqual("/services/data/" + TEST_API_VERSION + "/", request.Path, "Wrong path"); Assert.IsNull(request.Body, "Wrong request body"); Assert.IsNull(request.AdditionalHeaders, "Wrong additional headers"); }
public async Task TestCallWithBadAuthToken() { var unauthenticatedRestClient = new RestClient(TestCredentials.INSTANCE_SERVER, BAD_TOKEN, null); RestResponse response = await unauthenticatedRestClient.SendAsync(RestRequest.GetRequestForResources(TestCredentials.API_VERSION)); Assert.IsFalse(response.Success, "Success not expected"); Assert.IsNotNull(response.Error, "Expected error"); Assert.AreEqual(HttpStatusCode.Unauthorized.ToString().ToLower(), response.StatusCode.ToString().ToLower(), "Expected 401"); }
public async Task TestCallWithBadAuthToken() { var unauthenticatedRestClient = new RestClient(TestCredentials.InstanceServer, BadToken, null); var response = await unauthenticatedRestClient.SendAsync(RestRequest.GetRequestForResources(new TestCredentials().ApiVersion)); Assert.IsFalse(response.Success, "Success not expected"); Assert.IsNotNull(response.Error, "Expected error"); Assert.AreEqual(HttpStatusCode.Unauthorized.ToString().ToLower(), response.StatusCode.ToString().ToLower(), "Expected 401"); }
public void TestCallWithBadAuthTokenAndTokenProvider() { RestClient unauthenticatedRestClient = new RestClient(TestCredentials.INSTANCE_SERVER, BAD_TOKEN, () => Task.Factory.StartNew(() => _accessToken)); Assert.AreEqual(BAD_TOKEN, unauthenticatedRestClient.AccessToken, "RestClient should be using the bad token initially"); RestResponse response = unauthenticatedRestClient.SendSync(RestRequest.GetRequestForResources(TestCredentials.API_VERSION)); Assert.IsTrue(response.Success, "Success expected"); Assert.IsNull(response.Error, "Expected error"); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "Expected 200"); Assert.AreEqual(_accessToken, unauthenticatedRestClient.AccessToken, "RestClient should now using the good token"); }
public async Task TestCallWithBadAuthTokenAndTokenProvider() { var unauthenticatedRestClient = new RestClient(TestCredentials.InstanceServer, BadToken, (cancellationToken) => Task.Factory.StartNew(() => _accessToken)); Assert.AreEqual(BadToken, unauthenticatedRestClient.AccessToken, "RestClient should be using the bad token initially"); var response = await unauthenticatedRestClient.SendAsync(RestRequest.GetRequestForResources(new TestCredentials().ApiVersion)); Assert.IsTrue(response.Success, "Success expected"); Assert.IsNull(response.Error, "Expected error"); Assert.AreEqual(HttpStatusCode.OK.ToString().ToLower(), response.StatusCode.ToString().ToLower(), "Expected 200"); Assert.AreEqual(_accessToken, unauthenticatedRestClient.AccessToken, "RestClient should now using the good token"); }