public async Task WhenUsernameIsNotRight() { var action = new JiraCredentialsConnectivityCheckAction(store, httpClientFactory, log); var octoRequest = Substitute.For <IOctoRequest>(); var baseUrl = store.GetBaseUrl(); octoRequest.GetBody(Arg.Any <RequestBodyRegistration <JiraCredentialsConnectionCheckData> >()) .Returns(new JiraCredentialsConnectionCheckData { BaseUrl = baseUrl, Username = "******", Password = "******" }); var response = await action.ExecuteAsync(octoRequest); var connectivityCheckResponse = (ConnectivityCheckResponse)((OctoDataResponse)response.Response).Model; connectivityCheckResponse.Messages.ShouldNotBeEmpty(); connectivityCheckResponse.Messages.First().Message.ShouldStartWith($"Failed to connect to {baseUrl}. Response code: Unauthorized"); }
public async Task WhenInvalidUrlIsUsed(string baseUrl) { var action = new JiraCredentialsConnectivityCheckAction(store, httpClientFactory, log); var octoRequest = Substitute.For <IOctoRequest>(); octoRequest.GetBody(Arg.Any <RequestBodyRegistration <JiraCredentialsConnectionCheckData> >()) .Returns(new JiraCredentialsConnectionCheckData { BaseUrl = baseUrl, Username = "******", Password = "******" }); var response = await action.ExecuteAsync(octoRequest); var connectivityCheckResponse = (ConnectivityCheckResponse)((OctoDataResponse)response.Response).Model !; connectivityCheckResponse.Messages.ShouldNotBeEmpty(); connectivityCheckResponse.Messages.First().Category.ShouldBe(ConnectivityCheckMessageCategory.Error); connectivityCheckResponse.Messages.First().Message.ShouldBe("Invalid data received."); }