Example #1
0
        public void CanSetGatewayCredentialSupportsShouldProcess()
        {
            commandRuntimeMock.Setup(c => c.ShouldProcess(ClusterName, It.IsAny <string>())).Returns(true);

            hdinsightManagementMock.Setup(
                c =>
                c.UpdateGatewayCredential(ResourceGroupName, ClusterName,
                                          It.Is <UpdateGatewaySettingsParameters>(
                                              param =>
                                              param.IsCredentialEnabled.HasValue && param.UserName == _httpCred.UserName &&
                                              param.Password == _httpCred.Password.ConvertToString())))
            .Verifiable();

            var gatewaySettings = new GatewaySettings("true", _httpCred.UserName, _httpCred.Password.ConvertToString());

            hdinsightManagementMock.Setup(c => c.GetGatewaySettings(ResourceGroupName, ClusterName))
            .Returns(gatewaySettings)
            .Verifiable();

            setcmdlet.ExecuteCmdlet();

            commandRuntimeMock.VerifyAll();
            commandRuntimeMock.Verify(
                f => f.WriteObject(
                    It.Is <AzureHDInsightGatewaySettings>(
                        rsp =>
                        rsp.IsCredentialEnabled == gatewaySettings.IsCredentialEnabled &&
                        rsp.UserName == gatewaySettings.UserName &&
                        rsp.Password == gatewaySettings.Password)),
                Times.Once);
        }
Example #2
0
        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);
        }