Expect(cliApp.Email).To(Equal("*****@*****.**")) Expect(cliApp.Usage).To(Equal(cli_app_factory.LtcUsage)) Expect(cliApp.Commands).NotTo(BeEmpty()) Expect(cliApp.Action).ToNot(BeNil()) Expect(cliApp.CommandNotFound).ToNot(BeNil()) By("writing to the App.Writer", func() { cliApp.Writer.Write([]byte("write_sample")) Expect(outputBuffer).To(test_helpers.Say("write_sample")) }) }) Context("when targeted at a dav blob store", func() { BeforeEach(func() { cliConfig.SetBlobStore("http://test.com", "9999", "username", "password") }) It("instantiates a new dav blob store object", func() { }) }) Context("when invoked without latticeVersion set", func() { BeforeEach(func() { diegoVersion = "" latticeVersion = "" }) It("defaults the version", func() { Expect(cliApp).NotTo(BeNil())
<D:status>HTTP/1.1 200 OK</D:status> </D:propstat> </D:response> </D:multistatus> ` responseBodyRoot = strings.Replace(responseBodyRoot, "http://192.168.11.11:8444", fakeServer.URL(), -1) }) Context("when the DAV blob store does not require auth", func() { It("should return authorized", func() { fakeServer.RouteToHandler("PROPFIND", "/blobs/", ghttp.CombineHandlers( ghttp.VerifyHeaderKV("Depth", "1"), ghttp.RespondWith(207, responseBodyRoot, http.Header{"Content-Type": []string{"text/xml"}}), )) config.SetBlobStore(serverHost, serverPort, "", "") authorized, err := verifier.Verify(config) Expect(err).NotTo(HaveOccurred()) Expect(authorized).To(BeTrue()) Expect(fakeServer.ReceivedRequests()).To(HaveLen(1)) }) }) Context("when the DAV blob store requires auth", func() { It("should return authorized for proper credentials", func() { fakeServer.RouteToHandler("PROPFIND", "/blobs/", ghttp.CombineHandlers( ghttp.VerifyBasicAuth("good-user", "good-pass"), ghttp.VerifyHeaderKV("Depth", "1"), ghttp.RespondWith(207, responseBodyRoot, http.Header{"Content-Type": []string{"text/xml"}}), ))
err := dropletRunner.UploadBits("droplet-name", "some non-existent file") Expect(reflect.TypeOf(err).String()).To(Equal("*os.PathError")) }) It("returns an error when the upload fails", func() { fakeBlobStore.UploadReturns(errors.New("some error")) err := dropletRunner.UploadBits("droplet-name", tmpFile.Name()) Expect(err).To(MatchError("some error")) }) }) }) Describe("BuildDroplet", func() { It("does the build droplet task", func() { config.SetBlobStore("blob-host", "7474", "dav-user", "dav-pass") Expect(config.Save()).To(Succeed()) blobURL := fmt.Sprintf("http://%s:%s@%s:%s%s", config.BlobStore().Username, config.BlobStore().Password, config.BlobStore().Host, config.BlobStore().Port, "/blobs/droplet-name") fakeBlobStore.DownloadAppBitsActionReturns(models.WrapAction(&models.DownloadAction{ From: blobURL + "/bits.zip", To: "/tmp/app", User: "******", }))
BeforeEach(func() { fakeDAVVerifier = &fake_blob_store_verifier.FakeVerifier{} fakeS3Verifier = &fake_blob_store_verifier.FakeVerifier{} verifier = blob_store.BlobStoreVerifier{ DAVBlobStoreVerifier: fakeDAVVerifier, S3BlobStoreVerifier: fakeS3Verifier, } }) Context("when a dav blob store is targeted", func() { var config *config_package.Config BeforeEach(func() { config = config_package.New(nil) config.SetBlobStore("some-host", "some-port", "some-user", "some-password") }) It("returns a new DavBlobStore Verifier", func() { verifier.Verify(config) Expect(fakeDAVVerifier.VerifyCallCount()).To(Equal(1)) Expect(fakeS3Verifier.VerifyCallCount()).To(Equal(0)) }) }) Context("when an s3 blob store is targeted", func() { var config *config_package.Config BeforeEach(func() { config = config_package.New(nil) config.SetS3BlobStore("", "", "some-bucket-name", "")
}) It("informs the user the target is not set", func() { Expect(outputBuffer).To(test_helpers.SayLine("Target not set.")) }) }) Context("when no blob store is targeted", func() { It("should specify that no blob store is targeted", func() { Expect(outputBuffer).To(test_helpers.SayLine("\tNo droplet store specified.")) }) }) Context("when a DAV blob store is targeted", func() { BeforeEach(func() { config.SetBlobStore("blobtarget.com", "8444", "blobUser", "password") Expect(config.Save()).To(Succeed()) }) It("outputs the current user and blob store host", func() { Expect(outputBuffer).To(test_helpers.SayLine("Droplet store:\[email protected]:8444")) }) Context("when no blob store username is set", func() { BeforeEach(func() { config.SetBlobStore("blobtarget.com", "8444", "", "") Expect(config.Save()).To(Succeed()) }) It("only prints the blob store host", func() { Expect(outputBuffer).To(test_helpers.SayLine("Droplet store:\tblobtarget.com:8444"))
}) Describe("ActiveBlobStore", func() { It("defaults to 'dav'", func() { Expect(testConfig.ActiveBlobStore().String()).To(Equal("dav")) }) It("reports the active blobstore", func() { testConfig.SetS3BlobStore("some-access-key", "some-secret-key", "some-bucket-name", "some-s3-region") Expect(testConfig.ActiveBlobStore().String()).To(Equal("s3")) }) }) Describe("TargetBlob", func() { It("sets the blob target", func() { testConfig.SetBlobStore("some-host", "7474", "some-username", "some-password") Expect(testConfig.BlobStore()).To(Equal(config.BlobStoreConfig{ Host: "some-host", Port: "7474", Username: "******", Password: "******", })) }) It("sets the activeBlobStore to 'dav'", func() { testConfig.SetS3BlobStore("some-access-key", "some-secret-key", "some-bucket-name", "some-region") testConfig.SetBlobStore("some-host", "7474", "some-username", "some-password") Expect(testConfig.ActiveBlobStore().String()).To(Equal("dav")) }) })