Skip to content

Commit

Permalink
Merge pull request #7343 from habitat-sh/sm/fix-studio-ssl-tests
Browse files Browse the repository at this point in the history
Fix broken studio e2e tests
  • Loading branch information
smacfarlane committed Jan 17, 2020
2 parents 57dc43d + 44fb269 commit f70ca90
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
3 changes: 3 additions & 0 deletions components/studio/bin/hab-studio.ps1
Expand Up @@ -507,9 +507,12 @@ function Update-SslCertFile {
$studio_ssl_cert_file = (Join-Path $env:HAB_CACHE_SSL_PATH $cert_filename)
if (Test-Path $studio_ssl_cert_file) {
$env:SSL_CERT_FILE = $studio_ssl_cert_file
} else {
$env:SSL_CERT_FILE = $null
}
} catch {
Write-HabInfo "Unable to set SSL_CERT_FILE from '$env:SSL_CERT_FILE'"
$env:SSL_CERT_FILE = $null
}
}
}
Expand Down
30 changes: 25 additions & 5 deletions test/end-to-end/test_studio_with_ssl_cert_file_envvar_set.ps1
Expand Up @@ -18,10 +18,12 @@ if($IsLinux) {
$sslCertFileCheck = "test -f `$SSL_CERT_FILE"
$sslCertFilePrint = "echo `$SSL_CERT_FILE"
$sslCacheCertFileCheck = "test -f '/hab/cache/ssl/$e2e_certname'"
$sslCertFileNotSetCheck = "test ! -v SSL_CERT_FILE"
} else {
$sslCertFileCheck = "exit (!(Test-Path `$env:SSL_CERT_FILE))"
$sslCertFilePrint = "`$env:SSL_CERT_FILE.Replace('\','/')"
$sslCacheCertFileCheck = "exit (!(Test-Path '/hab/cache/ssl/$e2e_certname'))"
$sslCertFIleNotSetCheck = "exit `$(!!(`$env:SSL_CERT_FILE))"
}

Context "SSL_CERT_FILE is passed into the studio" {
Expand Down Expand Up @@ -88,9 +90,19 @@ Context "SSL_CERT_FILE is passed into the studio" {
Describe "SSL_CERT_FILE is a directory" {
$env:SSL_CERT_FILE = (Join-Path $tempdir "cert-as-directory")
New-Item -ItemType Directory -Force -Path $env:SSL_CERT_FILE

It "Should not set SSL_CERT_FILE" {
Invoke-StudioRun $sslCertFileNotSetCheck
$LASTEXITCODE | Should -Be 0
}

It "Should not copy the directory into the studio" {
Invoke-StudioRun $sslCertFileCheck
if($isLinux) {
Invoke-StudioRun "test -e /hab/cache/ssl/cert-as-directory"
} else {
Invoke-StudioRun $sslCertFileCheck
}

$LASTEXITCODE | Should -Be 1
}

Expand All @@ -107,10 +119,19 @@ Context "SSL_CERT_FILE is passed into the studio" {
}

It "Should not copy the file into the studio" {
Invoke-StudioRun $sslCertFileCheck
if($isLinux) {
Invoke-StudioRun "test -e /hab/cache/ssl/non-existant-file"
} else {
Invoke-StudioRun $sslCertFileCheck
}
$LASTEXITCODE | Should -Be 1
}

It "Should not set SSL_CERT_FILE" {
Invoke-StudioRun $sslCertFileNotSetCheck
$LASTEXITCODE | Should -Be 0
}

It "Can still search packages on builder" {
$result = Invoke-StudioRun "hab pkg search core/nginx"
$result | Should -Contain "core/nginx"
Expand All @@ -130,10 +151,9 @@ Context "SSL_CERT_FILE isn't set" {
}

Describe "Studio is auto-installed on first run" {

It "Should not set SSL_CERT_FILE in the studio" {
$result = hab studio run '$env:SSL_CERT_FILE -eq $null'
$result[-1]| Should -be "True"
Invoke-StudioRun $sslCertFileNotSetCheck
$LASTEXITCODE | Should -Be 0
}
}
}

0 comments on commit f70ca90

Please sign in to comment.