Skip to content

Commit

Permalink
check if @ServerName already present with username don't append serve…
Browse files Browse the repository at this point in the history
…r name (#3428)
  • Loading branch information
Ajay Kumar Yadav authored and vincent1173 committed Jan 19, 2017
1 parent 3d1bcb1 commit 815be8e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions Tasks/SqlAzureDacpacDeployment/Tests/L0UtilityGetSqlCmdArgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ $sqlPackageCommandLineArguments = Get-SqlPackageCommandArguments -dacpacFile "az
Assert-AreEqual '/SourceFile:"azureDacpac.dacpac" /Action:Publish /TargetConnectionString:"connectionString:10/20/30" /Profile:"Profile.xml" Add_args' `
$sqlPackageCommandLineArguments "Should have constructed Argument for Connection String"

$sqlPackageCommandLineArguments = Get-SqlPackageCommandArguments -dacpacFile "azureDacpac.dacpac" -targetMethod "server" -serverName "yyy.database.windows.net" `
-databaseName "databaseName" -sqlUsername "user@sql" -sqlPassword "sqlPassword" -publishProfile "Profile.xml" -additionalArguments "Add_args"

Assert-AreEqual '/SourceFile:"azureDacpac.dacpac" /Action:Publish /TargetServerName:"yyy.database.windows.net" /TargetDatabaseName:"databaseName" /TargetUser:"user@sql@yyy.database.windows.net" /TargetPassword:"sqlPassword" /Profile:"Profile.xml" Add_args' `
$sqlPackageCommandLineArguments "Should have constructed Argument for TargetMethod Server"

$sqlPackageCommandLineArguments = Get-SqlPackageCommandArguments -dacpacFile "azureDacpac.dacpac" -targetMethod "server" -serverName "yyy.database.windows.net" `
-databaseName "databaseName" -sqlUsername "sqluser@yyy.database.windows.net" -sqlPassword "sqlPassword" -publishProfile "Profile.xml" -additionalArguments "Add_args"

Assert-AreEqual '/SourceFile:"azureDacpac.dacpac" /Action:Publish /TargetServerName:"yyy.database.windows.net" /TargetDatabaseName:"databaseName" /TargetUser:"sqluser@yyy.database.windows.net" /TargetPassword:"sqlPassword" /Profile:"Profile.xml" Add_args' `
$sqlPackageCommandLineArguments "Should have constructed Argument for TargetMethod Server"

Assert-Throws {
Get-SqlPackageCommandArguments -dacpacFile "azureDacpac.dacpac" -targetMethod "connectionString" -connectionString "connectionString:10/20/30" -publishProfile "Profile.json" `
-additionalArguments "Add_args" -isOutputSecure
Expand Down
2 changes: 1 addition & 1 deletion Tasks/SqlAzureDacpacDeployment/Utility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function Get-SqlPackageCommandArguments

if($sqlUsername)
{
if($sqlUsername.Contains('@'))
if((-not $sqlUsername.Trim().EndsWith("@" + $serverName.Trim())) -and $sqlUsername.Contains('@'))
{
$sqlUsername = $sqlUsername + "@" + $serverName
}
Expand Down
2 changes: 1 addition & 1 deletion Tasks/SqlAzureDacpacDeployment/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 1,
"Minor": 1,
"Patch": 4
"Patch": 5
},
"demands": [
"sqlpackage"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/SqlAzureDacpacDeployment/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 1,
"Minor": 1,
"Patch": 4
"Patch": 5
},
"demands": [
"sqlpackage"
Expand Down

0 comments on commit 815be8e

Please sign in to comment.