public async Task QueryAsync_WhenInvalidIndexName_Returns403() { ConfigContextBase.SearchUris.Add(new FailureCountingUri("http://10.141.151.101:8091/")); var fakeMessageHandler = new FakeMessageHandler { StatusCode = HttpStatusCode.Forbidden, Content = new StringContent("rest_auth: preparePerm, err: index not found ") }; var client = new FakeSearchClient(new BucketConfig(), new ClientConfiguration(), new SearchDataMapper()) { HttpClient = new HttpClient(fakeMessageHandler), }; var response = await client.QueryAsync(new SearchQuery { Index = "indexdoesnotexist", Query = new MatchQuery("foo") }); Assert.IsTrue(response.Exception.Message.Contains("403")); }
public async Task Query_WhenInvalidUri_Returns404() { ConfigContextBase.SearchUris.Add(new FailureCountingUri("http://10.141.151.101:8091/")); var fakeMessageHandler = new FakeMessageHandler { StatusCode = HttpStatusCode.NotFound, Content = new StringContent("Requested resource not found. ") }; var client = new FakeSearchClient(new BucketConfig(), new ClientConfiguration(), new SearchDataMapper()) { HttpClient = new HttpClient(fakeMessageHandler), }; var response = await client.QueryAsync(new SearchQuery { Index = "indexdoesnotexist", Query = new MatchQuery("foo") }); Assert.IsTrue(response.Exception.Message.Contains("404")); }