Skip to content

Commit

Permalink
don't attempt to stream-convert http files that require creds
Browse files Browse the repository at this point in the history
  • Loading branch information
mhenriks committed Sep 7, 2018
1 parent 46528ff commit d9bbc4e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hack/build/docker/cdi-func-test-file-host-init/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM fedora:28

RUN mkdir -p /tmp/shared /tmp/source

RUN yum install -y qemu-img
RUN yum install -y qemu-img qemu-block-curl && dnf clean all

COPY cdi-func-test-file-host-init /usr/bin/

Expand Down
6 changes: 5 additions & 1 deletion pkg/importer/dataStream.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,11 @@ func closeReaders(readers []reader) (rtnerr error) {
}

func (d *DataStream) isHTTPQcow2() bool {
return (d.url.Scheme == "http" || d.url.Scheme == "https") && d.qemu && len(d.Readers) == 2
return (d.url.Scheme == "http" || d.url.Scheme == "https") &&
d.accessKeyID == "" &&
d.secretKey == "" &&
d.qemu &&
len(d.Readers) == 2
}

// Copy endpoint to dest based on passed-in reader.
Expand Down
11 changes: 8 additions & 3 deletions tests/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
var _ = Describe("Transport Tests", func() {

const (
secretPrefix = "transport-e2e-sec"
targetFile = "tinyCore.iso"
secretPrefix = "transport-e2e-sec"
targetFile = "tinyCore.iso"
targetQCOWFile = "tinyCore.qcow2"
)

f, err := framework.NewFramework("", framework.Config{SkipNamespaceCreation: false})
Expand All @@ -37,7 +38,9 @@ var _ = Describe("Transport Tests", func() {
handelError(err)

httpAuthEp := fmt.Sprintf("http://%s:%d/%s", fileHostService.Spec.ClusterIP, httoAuthPort, targetFile)
httpAuthQCOWEp := fmt.Sprintf("http://%s:%d/%s", fileHostService.Spec.ClusterIP, httoAuthPort, targetQCOWFile)
httpNoAuthEp := fmt.Sprintf("http://%s:%d/%s", fileHostService.Spec.ClusterIP, noAuthPort, targetFile)
httpNoAuthQCOWEp := fmt.Sprintf("http://%s:%d/%s", fileHostService.Spec.ClusterIP, noAuthPort, targetQCOWFile)

var ns string
BeforeEach(func() {
Expand Down Expand Up @@ -84,7 +87,9 @@ var _ = Describe("Transport Tests", func() {

DescribeTable("Transport Test Table", it,
Entry("should connect to http endpoint without credentials", httpNoAuthEp, false),
Entry("should connect to http endpoint with credentials", httpAuthEp, true))
Entry("should connect to http endpoint with credentials", httpAuthEp, true),
Entry("should connect to QCOW http endpoint without credentials", httpNoAuthQCOWEp, false),
Entry("should connect to QCOW http endpoint with credentials", httpAuthQCOWEp, true))
})

// handelError is intended for use outside It(), BeforeEach() and AfterEach() blocks where Expect() cannot be called.
Expand Down

0 comments on commit d9bbc4e

Please sign in to comment.