mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Support creating & editing additional user types (#1962)
* WIP * Fix contained user password handling * More user related bug fixes
This commit is contained in:
@@ -54,8 +54,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Security
|
||||
IsLockedOut = false,
|
||||
EnforcePasswordPolicy = false,
|
||||
EnforcePasswordExpiration = false,
|
||||
Password = "placeholder",
|
||||
OldPassword = "placeholder",
|
||||
Password = "placeholder" + new Random().NextInt64(10000000, 90000000).ToString() + "!*PLACEHOLDER",
|
||||
OldPassword = "placeholder" + new Random().NextInt64(10000000, 90000000).ToString() + "!*PLACEHOLDER",
|
||||
DefaultLanguage = "English - us_english",
|
||||
DefaultDatabase = "master"
|
||||
};
|
||||
@@ -66,9 +66,10 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Security
|
||||
return new UserInfo()
|
||||
{
|
||||
Type = userType,
|
||||
AuthenticationType = ServerAuthenticationType.Sql,
|
||||
Name = userName ?? "TestUserName_" + new Random().NextInt64(10000000, 90000000).ToString(),
|
||||
LoginName = loginName,
|
||||
Password = "placeholder",
|
||||
Password = "placeholder" + new Random().NextInt64(10000000, 90000000).ToString() + "!*PLACEHOLDER",
|
||||
DefaultSchema = "dbo",
|
||||
OwnedSchemas = new string[] { "" }
|
||||
};
|
||||
@@ -163,7 +164,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Security
|
||||
TestConnectionResult connectionResult,
|
||||
DatabaseUserType userType,
|
||||
string userName = null,
|
||||
string loginName = null)
|
||||
string loginName = null,
|
||||
string databaseName = "master")
|
||||
{
|
||||
string contextId = System.Guid.NewGuid().ToString();
|
||||
var initializeViewRequestParams = new InitializeUserViewParams
|
||||
@@ -171,7 +173,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Security
|
||||
ConnectionUri = connectionResult.ConnectionInfo.OwnerUri,
|
||||
ContextId = contextId,
|
||||
IsNewObject = true,
|
||||
Database = "master"
|
||||
Database = databaseName
|
||||
};
|
||||
|
||||
var initializeUserViewContext = new Mock<RequestContext<UserViewInfo>>();
|
||||
|
||||
@@ -64,6 +64,32 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Security
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the basic Create User method handler
|
||||
/// </summary>
|
||||
// [Test] - needs contained DB
|
||||
public async Task TestHandleCreateUserWithContainedSqlPassword()
|
||||
{
|
||||
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
||||
{
|
||||
// setup
|
||||
SecurityService service = new SecurityService();
|
||||
UserServiceHandlerImpl userService = new UserServiceHandlerImpl();
|
||||
string databaseName = "CRM";
|
||||
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync(databaseName, queryTempFile.FilePath);
|
||||
|
||||
var user = await SecurityTestUtils.CreateUser(
|
||||
userService,
|
||||
connectionResult,
|
||||
DatabaseUserType.Contained,
|
||||
userName: null,
|
||||
loginName: null,
|
||||
databaseName: connectionResult.ConnectionInfo.ConnectionDetails.DatabaseName);
|
||||
|
||||
await SecurityTestUtils.DropObject(connectionResult.ConnectionInfo.OwnerUri, SecurityTestUtils.GetUserURN(connectionResult.ConnectionInfo.ConnectionDetails.DatabaseName, user.Name));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the basic Update User method handler
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user