public void CanRevokeHttpAccess() { hdinsightManagementMock.Setup( c => c.ConfigureHttp(ResourceGroupName, ClusterName, It.Is <HttpSettingsParameters>( param => !param.HttpUserEnabled && string.IsNullOrEmpty(param.HttpPassword) && string.IsNullOrEmpty(param.HttpUsername)))) .Returns(new OperationResource { ErrorInfo = null, StatusCode = HttpStatusCode.OK, State = AsyncOperationState.Succeeded }) .Verifiable(); var connectivitysettings = new HttpConnectivitySettings { HttpUserEnabled = false, StatusCode = HttpStatusCode.OK }; hdinsightManagementMock.Setup(c => c.GetConnectivitySettings(ResourceGroupName, ClusterName)) .Returns(connectivitysettings) .Verifiable(); revokecmdlet.ExecuteCmdlet(); commandRuntimeMock.VerifyAll(); commandRuntimeMock.Verify(f => f.WriteObject(connectivitysettings), Times.Once); }
public void CanGrantHttpAccess() { hdinsightManagementMock.Setup( c => c.ConfigureHttp(ResourceGroupName, ClusterName, It.Is <HttpSettingsParameters>( param => param.HttpUserEnabled && param.HttpUsername == _httpCred.UserName && param.HttpPassword == _httpCred.Password.ConvertToString()))) .Returns(new OperationResource { ErrorInfo = null, StatusCode = HttpStatusCode.OK, State = AsyncOperationState.Succeeded }) .Verifiable(); var connectivitysettings = new HttpConnectivitySettings { HttpPassword = _httpCred.Password.ConvertToString(), HttpUserEnabled = true, HttpUsername = _httpCred.UserName, StatusCode = HttpStatusCode.OK }; hdinsightManagementMock.Setup(c => c.GetConnectivitySettings(ResourceGroupName, ClusterName)) .Returns(connectivitysettings) .Verifiable(); grantcmdlet.ExecuteCmdlet(); commandRuntimeMock.VerifyAll(); commandRuntimeMock.Verify(f => f.WriteObject(connectivitysettings), Times.Once); }
private void ValidateHttpSettings(IDictionary <string, string> httpSettings, string expectedUsername, string expectedPassword) { Assert.NotNull(httpSettings); HttpConnectivitySettings settings = JsonConvert.DeserializeObject <HttpConnectivitySettings>(JsonConvert.SerializeObject(httpSettings)); Assert.Equal("true", settings.EnabledCredential); Assert.Equal(expectedUsername, settings.Username); Assert.Equal(expectedPassword, settings.Password); }
public static Dictionary <string, string> Convert(HttpConnectivitySettings configuration) { return(new Dictionary <string, string> { { Constants.GatewayConfigurations.CredentialIsEnabledKey, configuration.EnabledCredential }, { Constants.GatewayConfigurations.UserNameKey, configuration.Username }, { Constants.GatewayConfigurations.PasswordKey, configuration.Password } }); }
public async Task <AzureOperationResponse> BeginEnablingHttpAsync(string resourceGroupName, string clusterName, string username, string password, CancellationToken cancellationToken) { try { HttpConnectivitySettings settings = GetEnableParameters(username, password); return(await BeginUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, ConfigurationKey.Gateway, ConfigurationsConverter.Convert(settings), null, cancellationToken)); } catch (Exception ex) { throw new CloudException(ex.Message); } }
public void TestGetConfigurations() { string clusterName = "hdisdk-configs"; string testName = "TestGetConfigurations"; string suiteName = GetType().FullName; ClusterCreateParameters createParams = ClusterCreateParametersHelpers.GetCustomCreateParametersIaas(testName); Dictionary <string, string> hiveConfig = new Dictionary <string, string> { { "key1", "value1" }, { "key2", "value2" } }; Dictionary <string, string> mapredConfig = new Dictionary <string, string> { { "key5", "value5" }, { "key6", "value6" } }; Dictionary <string, string> yarnConfig = new Dictionary <string, string> { { "key7", "value7" }, { "key8", "value8" } }; createParams.Configurations.Add(ConfigurationKey.HiveSite, hiveConfig); createParams.Configurations.Add(ConfigurationKey.MapRedSite, mapredConfig); createParams.Configurations.Add(ConfigurationKey.YarnSite, yarnConfig); HDInsightManagementTestUtilities.CreateClusterInNewResourceGroupAndRunTest(suiteName, testName, clusterName, createParams, (client, rgName) => { var hive = client.Configurations.Get(rgName, clusterName, ConfigurationKey.HiveSite); Assert.Equal(hiveConfig, hive); var mapred = client.Configurations.Get(rgName, clusterName, ConfigurationKey.MapRedSite); Assert.Equal(mapredConfig, mapred); var yarn = client.Configurations.Get(rgName, clusterName, ConfigurationKey.YarnSite); Assert.Equal(yarnConfig, yarn); var gateway = client.Configurations.Get(rgName, clusterName, ConfigurationKey.Gateway); Assert.Equal(3, gateway.Count); HttpConnectivitySettings settings = JsonConvert.DeserializeObject <HttpConnectivitySettings>(JsonConvert.SerializeObject(gateway)); Assert.NotNull(settings); var core = client.Configurations.Get(rgName, clusterName, ConfigurationKey.CoreSite); Assert.Equal(2, core.Count); Assert.True(core.ContainsKey(Constants.StorageConfigurations.DefaultFsKey)); string storageKeyFormat = Constants.StorageConfigurations.WasbStorageAccountKeyFormat; string storageKeyPrefix = storageKeyFormat.Substring(0, storageKeyFormat.IndexOf("{")); Assert.Contains(core, c => c.Key.StartsWith(storageKeyPrefix)); }); }
public void CanSetGatewayCredentialSupportsShouldProcess() { commandRuntimeMock.Setup(c => c.ShouldProcess(ClusterName, It.IsAny <string>())).Returns(true); hdinsightManagementMock.Setup( c => c.UpdateGatewayCredential(ResourceGroupName, ClusterName, It.Is <HttpSettingsParameters>( param => param.HttpUserEnabled && param.HttpUsername == _httpCred.UserName && param.HttpPassword == _httpCred.Password.ConvertToString()))) .Returns(new OperationResource { ErrorInfo = null, StatusCode = HttpStatusCode.OK, State = AsyncOperationState.Succeeded }) .Verifiable(); var gatewayCredential = new HttpConnectivitySettings { HttpPassword = _httpCred.Password.ConvertToString(), HttpUserEnabled = true, HttpUsername = _httpCred.UserName, StatusCode = HttpStatusCode.OK }; hdinsightManagementMock.Setup(c => c.GetGatewaySettings(ResourceGroupName, ClusterName)) .Returns(gatewayCredential) .Verifiable(); setcmdlet.ExecuteCmdlet(); commandRuntimeMock.VerifyAll(); commandRuntimeMock.Verify(f => f.WriteObject(gatewayCredential), Times.Once); }