예제 #1
0
        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);
        }
예제 #2
0
        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);
        }