Inheritance: SqlStatement, IPreparable
        public async void AdminSetsAccountPassword(string userName, string password)
        {
            var statement = new AlterUserStatement(userName, new SetPasswordAction(password));
            var result    = await statement.ExecuteAsync(adminContext);

            Assert.NotNull(result);
            Assert.True(result.IsEmpty());
            Assert.Equal(userName, userSet);
            Assert.Equal(password, newPassword);
        }
        public async void AdminSetsAccountStatus(string userName, UserStatus status)
        {
            var statement = new AlterUserStatement(userName, new SetAccountStatusAction(status));
            var result    = await statement.ExecuteAsync(adminContext);

            Assert.NotNull(result);
            Assert.True(result.IsEmpty());
            Assert.Equal(userName, userSet);
            Assert.Equal(status, newStatus);
        }
        protected override SqlStatement VisitAlterUser(AlterUserStatement statement)
        {
            builder.AppendFormat("ALTER USER {0} ", statement.UserName);

            if (statement.AlterAction is SetUserRolesAction) {
                var setRoles = (SetUserRolesAction) statement.AlterAction;

                var roles = String.Join(", ", setRoles.Roles.Select(x => x.ToString()).ToArray());
                builder.AppendFormat(" SET ROLE ", roles);
            } else if (statement.AlterAction is SetPasswordAction) {
                var setPassword = (SetPasswordAction) statement.AlterAction;
                builder.AppendFormat(" SET PASSWORD {0}", setPassword.PasswordExpression);
            } else if (statement.AlterAction is SetAccountStatusAction) {
                var setStatus = (SetAccountStatusAction) statement.AlterAction;
                builder.AppendFormat(" SET ACCOUNT STATUS {0}", setStatus.ActionType.ToString().ToUpperInvariant());
            }

            return base.VisitAlterUser(statement);
        }
Exemple #4
0
        protected override SqlStatement VisitAlterUser(AlterUserStatement statement)
        {
            builder.AppendFormat("ALTER USER {0} ", statement.UserName);

            if (statement.AlterAction is SetUserRolesAction)
            {
                var setRoles = (SetUserRolesAction)statement.AlterAction;

                var roles = String.Join(", ", setRoles.Roles.Select(x => x.ToString()).ToArray());
                builder.AppendFormat(" SET ROLE ", roles);
            }
            else if (statement.AlterAction is SetPasswordAction)
            {
                var setPassword = (SetPasswordAction)statement.AlterAction;
                builder.AppendFormat(" SET PASSWORD {0}", setPassword.PasswordExpression);
            }
            else if (statement.AlterAction is SetAccountStatusAction)
            {
                var setStatus = (SetAccountStatusAction)statement.AlterAction;
                builder.AppendFormat(" SET ACCOUNT STATUS {0}", setStatus.ActionType.ToString().ToUpperInvariant());
            }

            return(base.VisitAlterUser(statement));
        }
Exemple #5
0
 protected virtual SqlStatement VisitAlterUser(AlterUserStatement statement)
 {
     return new AlterUserStatement(statement.UserName, statement.AlterAction);
 }
        public async void UserSetsAccountStatus(string userName, string password)
        {
            var statement = new AlterUserStatement(userName, new SetPasswordAction(password));

            await Assert.ThrowsAsync <UnauthorizedAccessException>(() => statement.ExecuteAsync(userContext));
        }
        public void SetAccountStatus_ToString(string userName, string password, string expected)
        {
            var statement = new AlterUserStatement(userName, new SetPasswordAction(password));

            Assert.Equal(expected, statement.ToSqlString());
        }
Exemple #8
0
 protected virtual SqlStatement VisitAlterUser(AlterUserStatement statement)
 {
     return(new AlterUserStatement(statement.UserName, statement.AlterAction));
 }