Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken studio e2e tests #7343

Merged
merged 5 commits into from Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}
}
}