/// <inheritdoc /> public Task InitializeAsync() { var serverHost = _settingsProvider.GetServer(); if (string.IsNullOrWhiteSpace(serverHost)) { throw new InvalidOperationException("Rocket.Chat server host cannot be empty."); } var authenticationData = new AuthenticationData { User = _settingsProvider.GetUserName(), Password = _settingsProvider.GetPassword(), AuthToken = _settingsProvider.GetAuthToken() }; var authDataValid = !string.IsNullOrEmpty(authenticationData.AuthToken) || (!string.IsNullOrEmpty(authenticationData.User) && !string.IsNullOrEmpty(authenticationData.Password)); if (!authDataValid) { throw new InvalidOperationException("Either AuthToken or both UserName and Password must be provided."); } return(_restApiClient.AuthenticateAsync(serverHost, authenticationData)); }
public async Task OneTimeSetup() { var httpClient = new HttpClient(); var httpClientWrapper = new HttpClientWrapper(httpClient); var logger = Mock.Of <ILogger <RestApiClient> >(); _client = new RestApiClient(httpClientWrapper, logger); var authData = new AuthenticationData { AuthToken = _authToken }; await _client.AuthenticateAsync(_server, authData).ConfigureAwait(false); }