public Migrator(MigrationConfigurationBase configuration, ServerStore serverStore) { _serverUrl = UrlHelper.TryGetLeftPart(configuration.ServerUrl); _serverStore = serverStore; _buildMajorVersion = configuration.BuildMajorVersion; _buildVersion = configuration.BuildVersion; //because of backward compatibility useCompression == false here var httpClientHandler = RequestExecutor.CreateHttpMessageHandler(_serverStore.Server.Certificate.Certificate, setSslProtocols: false, useCompression: false); httpClientHandler.UseDefaultCredentials = false; if (string.IsNullOrWhiteSpace(configuration.ApiKey) == false) { Authenticator.GetApiKeyParts(configuration.ApiKey); // will throw if not in correct format _apiKey = configuration.ApiKey; _enableBasicAuthenticationOverUnsecuredHttp = configuration.EnableBasicAuthenticationOverUnsecuredHttp; } else if (string.IsNullOrWhiteSpace(configuration.UserName) == false && string.IsNullOrWhiteSpace(configuration.Password) == false) { var domain = string.IsNullOrWhiteSpace(configuration.Domain) ? "\\" : configuration.Domain; httpClientHandler.Credentials = new NetworkCredential( configuration.UserName, configuration.Password, domain); } _httpClient = new HttpClient(httpClientHandler); }
public async Task MoveOnToNextTcpAddressOnGuidFailInPingTest() { using (var serverA = CreateSecuredServer()) using (var serverB = CreateSecuredServer(serverA.ServerStore.GetNodeTcpServerUrl(), false)) { using (var handler = RequestExecutor.CreateHttpMessageHandler(serverA.Certificate.Certificate, true, true)) using (var client = new HttpClient(handler)) { var url = $"{serverA.WebUrl}/admin/debug/node/ping?url={Uri.EscapeDataString(serverB.WebUrl)}"; var rawResponse = (await client.GetAsync(url)).Content.ReadAsStringAsync().Result; var res = JsonConvert.DeserializeObject <HttpPingResult>(rawResponse); Assert.NotNull(res); Assert.Equal(1, res.Result.Count); Assert.True(res.Result[0].Log.Count(exp => exp.Contains("but instead reached a server with Id")) > 0); } } }
public Migrator(MigrationConfigurationBase configuration, ServerStore serverStore) { _serverUrl = UrlHelper.TryGetLeftPart(configuration.ServerUrl); _serverStore = serverStore; _buildMajorVersion = configuration.BuildMajorVersion; _buildVersion = configuration.BuildVersion; var httpClientHandler = RequestExecutor.CreateHttpMessageHandler(_serverStore.Server.Certificate.Certificate, setSslProtocols: false); httpClientHandler.UseDefaultCredentials = false; if (string.IsNullOrWhiteSpace(configuration.UserName) == false && string.IsNullOrWhiteSpace(configuration.Password) == false) { var domain = string.IsNullOrWhiteSpace(configuration.Domain) ? "\\" : configuration.Domain; httpClientHandler.Credentials = new NetworkCredential( configuration.UserName, configuration.Password, domain); } _httpClient = new HttpClient(httpClientHandler); }