Skip to content
Permalink
Browse files

Added Azure tests (#5187)

* add connect tests

* fix wording

* add dll for adpasswd

adalsql.dll (Authentication=ActiveDirectoryPassword). Error code: 0x2. For more information, see http://go.microsoft.com/fwlink/?LinkID=513072

* fails too often

* removed sqlclient because it fails in core

* try one more time

* Revert "try one more time"

This reverts commit d361e08.

* fix horrible-adalsql-issue

* oops

* shh

* enable rdp

* moving things

* disable rdp

* perhaps this will work

* rdp once more

* try this

* Revert "try this"

This reverts commit ba7c8bd.

* remove that one test
  • Loading branch information...
potatoqualitee committed Mar 11, 2019
1 parent 48d7b4e commit 23eb4b9cb748d04e48a5c5d6fc1ebfaee8e0ac71
@@ -29,6 +29,8 @@ environment:
secure: ZnF3fWSDfHraMCWlHaekvWrXf3sDqY5M28HMK4236PBbNSoqP29wEhsWMQioSSYGomzgIp9vuiwR8Fc9ViNLoqq0bVcErxEojBFTaPMEzOg2ZwO9OnOTiuUEc5JkoLBv6rEBBWef/DvkFfhr1r0K0xQu6OAPYHVTCRajTZbBRNfCTUM2X2o41t+cSa7681rtnJQnB/8cAfVVnPtJ+97s8w==
azurelegacypasswd:
secure: ud4yZN6kPf+VWhgpgJhbEMCoUJKHTiH9uvv71ybTlu+45+V12M+B07YjysoXGC1qnGBwVy4DDGJfh2VkPWxamK0IpsEimsRS/CCEZlb6unYC4dqEm980QwP4/zwcTSK1
azuredbpasswd:
secure: JwVx9sps/1g/3eIBRvh21UGRpRAQnXk+7+zZyVmdWL0=

matrix:
- scenario: 2008R2
Binary file not shown.
@@ -56,8 +56,7 @@ $scriptBlock = {
'Microsoft.SqlServer.Types',
'Microsoft.SqlServer.Management.RegisteredServers',
'Microsoft.SqlTools.Hosting',
'Microsoft.SqlTools.ManagedBatchParser',
'System.Data.SqlClient'
'Microsoft.SqlTools.ManagedBatchParser'
)
} else {
$names = @(
@@ -5,7 +5,7 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')}
[object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','AccessToken','ApplicationIntent','AzureUnsupported','BatchSeparator','ClientName','ConnectTimeout','EncryptConnection','FailoverPartner','LockTimeout','MaxPoolSize','MinPoolSize','MinimumVersion','MultipleActiveResultSets','MultiSubnetFailover','NetworkProtocol','NonPooledConnection','PacketSize','PooledConnectionLifetime','SqlExecutionModes','StatementTimeout','TrustServerCertificate','WorkstationId','AppendConnectionString','SqlConnectionOnly','DisableException'
[object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'AccessToken', 'ApplicationIntent', 'AzureUnsupported', 'BatchSeparator', 'ClientName', 'ConnectTimeout', 'EncryptConnection', 'FailoverPartner', 'LockTimeout', 'MaxPoolSize', 'MinPoolSize', 'MinimumVersion', 'MultipleActiveResultSets', 'MultiSubnetFailover', 'NetworkProtocol', 'NonPooledConnection', 'PacketSize', 'PooledConnectionLifetime', 'SqlExecutionModes', 'StatementTimeout', 'TrustServerCertificate', 'WorkstationId', 'AppendConnectionString', 'SqlConnectionOnly', 'DisableException'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0
@@ -14,6 +14,19 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
}

Describe "$commandname Integration Tests" -Tags "IntegrationTests" {
if ($env:azuredbpasswd) {
Context "Connect to Azure" {
$securePassword = ConvertTo-SecureString $env:azuredbpasswd -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($script:azuresqldblogin, $securePassword)

It "Should login to Azure" {
$s = Connect-DbaInstance -SqlInstance $script:azureserver -SqlCredential $cred -Database test
$s.Name | Should -match $script:azureserver
$s.DatabaseEngineType | Should -Be 'SqlAzureDatabase'
}
}
}

Context "connection is properly made" {
$server = Connect-DbaInstance -SqlInstance $script:instance1 -ApplicationIntent ReadOnly

@@ -1,3 +1,76 @@

function Invoke-TlsWebRequest {
<#
Internal utility that mimics invoke-webrequest
but enables all tls available version
rather than the default, which on a lot
of standard installations is just TLS 1.0
#>
$currentVersionTls = [Net.ServicePointManager]::SecurityProtocol
$currentSupportableTls = [Math]::Max($currentVersionTls.value__, [Net.SecurityProtocolType]::Tls.value__)
$availableTls = [enum]::GetValues('Net.SecurityProtocolType') | Where-Object { $_ -gt $currentSupportableTls }
$availableTls | ForEach-Object {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor $_
}

Invoke-WebRequest @Args

[Net.ServicePointManager]::SecurityProtocol = $currentVersionTls
}

Function Install-ADAuthenticationLibraryforSQLServer {
# from https://bzzzt.io/post/2018-05-25-horrible-adalsql-issue/
$workingFolder = Join-Path $env:temp ([System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Force -Path $workingFolder
$uri = "https://raw.githubusercontent.com/sqlcollaborative/appveyor-lab/master/azure/adalsql.msi"


$splitArray = $uri -split "/"
$fileName = $splitArray[-1]

$Installer = Join-Path -Path $WorkingFolder -ChildPath $fileName
try {
Invoke-TlsWebRequest -Uri $uri -OutFile $Installer
} catch {
Throw $_.Exception
}
If (!(Test-Path $Installer)) {
Throw "$Installer does not exist"
}
try {
Write-Host "attempting to uninstall..."
Write-Host "Running MsiExec.exe /uninstall {4EE99065-01C6-49DD-9EC6-E08AA5B13491} /quiet"
Start-Process -FilePath "MsiExec.exe" -ArgumentList "/uninstall {4EE99065-01C6-49DD-9EC6-E08AA5B13491} /quiet" -Wait -NoNewWindow
} catch {
Write-Host "oh dear install did not work"
$fail = $_.Exception
Write-Error $fail
Throw
}
try {
$DataStamp = get-date -Format yyyyMMddTHHmmss
$logFile = '{0}-{1}.log' -f $Installer, $DataStamp
$MSIArguments = @(
"/i"
('"{0}"' -f $Installer)
"/qn"
"/norestart"
"/L*v"
$logFile
)
Write-Host "Attempting to install.."
Write-Host " Running msiexec.exe $($MSIArguments)"
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow
} catch {
$fail = $_.Exception
Write-Error $fail
Throw
}
}

$null = Install-ADAuthenticationLibraryforSQLServer

$indent = '...'
Write-Host -Object "$indent Running $PSCommandpath" -ForegroundColor DarkGreen
Import-Module C:\github\dbatools\dbatools.psm1 -Force
@@ -15,6 +15,8 @@ if (Test-Path C:\temp\constants.ps1) {
$ssisserver = "localhost\sql2016"
$script:azureblob = "https://dbatools.blob.core.windows.net/sql"
$script:azureblobaccount = "dbatools"
$script:azureserver = 'psdbatools.database.windows.net'
$script:azuresqldblogin = "appveyor@clemairegmail.onmicrosoft.com"
}

if ($env:appveyor) {
@@ -52,7 +52,8 @@ $TestsRunGroups = @{
'Resume-DbaAgDbDataMovement',
'Get-DbaDbMasterKey',
'Test-DbaAgentJobOwner',
'Stop-DbaXESession'
'Stop-DbaXESession',
'Get-DbaPrivilege'
)
# do not run everywhere
"disabled" = @()

0 comments on commit 23eb4b9

Please sign in to comment.
You can’t perform that action at this time.