fakeExitHandler = new(fake_exit_handler.FakeExitHandler)
		terminalUI = terminal.NewUI(stdinReader, outputBuffer, nil)
		config = config_package.New(persister.NewMemPersister())
	})

	Describe("TargetBlobCommand", func() {
		var targetBlobCommand cli.Command

		BeforeEach(func() {
			commandFactory := command_factory.NewConfigCommandFactory(config, terminalUI, fakeTargetVerifier, fakeExitHandler)
			targetBlobCommand = commandFactory.MakeTargetBlobCommand()
		})

		Context("displaying the blob target", func() {
			It("outputs the current target", func() {
				config.SetBlobTarget("192.168.11.11", 8980, "datkeyyo", "supersecretJKJK", "bucket")
				config.Save()

				test_helpers.ExecuteCommandWithArgs(targetBlobCommand, []string{})

				Expect(outputBuffer).To(test_helpers.Say("Blob Target:\t192.168.11.11:8980\n"))
				Expect(outputBuffer).To(test_helpers.Say("Access Key:\tdatkeyyo"))
				Expect(outputBuffer).To(test_helpers.Say("Secret Key:\tsupersecretJKJK"))
				Expect(outputBuffer).To(test_helpers.Say("Bucket Name:\tbucket"))
			})

			It("alerts the user if no target is set", func() {
				config.SetBlobTarget("", 0, "", "", "")
				config.Save()

				test_helpers.ExecuteCommandWithArgs(targetBlobCommand, []string{})
			responseBody   string
		)

		BeforeEach(func() {
			targetVerifier = target_verifier.New(func(string) receptor.Client {
				return &fake_receptor.FakeClient{}
			})
			fakeServer = ghttp.NewServer()

			config = config_package.New(persister.NewMemPersister())
			proxyURL, err := url.Parse(fakeServer.URL())
			Expect(err).NotTo(HaveOccurred())
			proxyHostArr := strings.Split(proxyURL.Host, ":")
			Expect(proxyHostArr).To(HaveLen(2))
			proxyHostPort, _ := strconv.Atoi(proxyHostArr[1])
			config.SetBlobTarget(proxyHostArr[0], uint16(proxyHostPort), "V8GDQFR_VDOGM55IV8OH", "Wv_kltnl98hNWNdNwyQPYnFhK4gVPTxVS3NNMg==", "bucket")

			httpHeader := http.Header{
				"Content-Type": []string{"application/xml"},
			}

			fakeServer.AppendHandlers(ghttp.CombineHandlers(
				ghttp.VerifyRequest("GET", "/bucket/"),
				ghttp.RespondWithPtr(&statusCode, &responseBody, httpHeader),
			))
		})

		It("returns ok=true if able to connect and auth and it exists", func() {
			statusCode = http.StatusOK
			responseBody = `<?xml version="1.0" encoding="UTF-8"?><ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>x</ID><DisplayName>x</DisplayName></Owner><Buckets><Bucket><Name>bucket</Name><CreationDate>2015-06-11T16:50:43.000Z</CreationDate></Bucket></Buckets></ListAllMyBucketsResult>`
Beispiel #3
0
			Expect(fakePersister.target).To(Equal("mysavedapi.com"))
			Expect(testConfig.Receptor()).To(Equal("http://*****:*****@receptor.mysavedapi.com"))
		})

		It("returns errors from loading the config", func() {
			testConfig = config.New(&fakePersister{err: errors.New("Error")})

			err := testConfig.Load()

			Expect(err).To(MatchError("Error"))
		})
	})

	Describe("TargetBlob", func() {
		It("sets the blob target", func() {
			testConfig.SetBlobTarget("s3-compatible-store", 7474, "NUYP3C_MBM-WDDWYKIUN", "Nb5vjT2V-ZX0O0s00xURSsg2Se0w-bmX40IQNg4==", "the-bucket")

			blobTarget := testConfig.BlobTarget()
			Expect(blobTarget.TargetHost).To(Equal("s3-compatible-store"))
			Expect(blobTarget.TargetPort).To(Equal(uint16(7474)))
			Expect(blobTarget.AccessKey).To(Equal("NUYP3C_MBM-WDDWYKIUN"))
			Expect(blobTarget.SecretKey).To(Equal("Nb5vjT2V-ZX0O0s00xURSsg2Se0w-bmX40IQNg4=="))
			Expect(blobTarget.BucketName).To(Equal("the-bucket"))
		})
	})

	Describe("BlobTargetInfo", func() {
		var blobTargetInfo config.BlobTargetInfo

		Describe("Proxy", func() {
			It("returns the proxy func", func() {
	)

	BeforeEach(func() {
		fakeAppRunner = &fake_app_runner.FakeAppRunner{}
		fakeTaskRunner = &fake_task_runner.FakeTaskRunner{}
		config = config_package.New(persister.NewMemPersister())
		fakeBlobStore = &fake_blob_store.FakeBlobStore{}
		fakeBlobBucket = &fake_blob_bucket.FakeBlobBucket{}
		fakeTargetVerifier = &fake_target_verifier.FakeTargetVerifier{}
		fakeAppExaminer = &fake_app_examiner.FakeAppExaminer{}
		dropletRunner = droplet_runner.New(fakeAppRunner, fakeTaskRunner, config, fakeBlobStore, fakeBlobBucket, fakeTargetVerifier, fakeAppExaminer)
	})

	Describe("ListDroplets", func() {
		It("returns a list of droplets in the blob store", func() {
			config.SetBlobTarget("blob-host", 7474, "access-key", "secret-key", "bucket-name")
			config.Save()

			fakeBlobBucket.ListStub = func(prefix, delim, marker string, max int) (result *s3.ListResp, err error) {
				switch prefix {
				case "":
					return &s3.ListResp{
						Name:           "bucket-name",
						Prefix:         "",
						Delimiter:      "/",
						CommonPrefixes: []string{"X/", "Y/", "Z/"},
					}, nil
				case "X/":
					return &s3.ListResp{
						Name:      "bucket-name",
						Prefix:    "X/",
		}

		BeforeEach(func() {
			targetVerifier = target_verifier.New(func(string) receptor.Client {
				return &fake_receptor.FakeClient{}
			})
			fakeServer = ghttp.NewServer()

			config = config_package.New(persister.NewMemPersister())
			proxyURL, err := url.Parse(fakeServer.URL())
			Expect(err).NotTo(HaveOccurred())
			proxyHostArr := strings.Split(proxyURL.Host, ":")
			Expect(proxyHostArr).To(HaveLen(2))
			proxyHostPort, err := strconv.Atoi(proxyHostArr[1])
			Expect(err).NotTo(HaveOccurred())
			config.SetBlobTarget(proxyHostArr[0], uint16(proxyHostPort), accessKey, secretKey, bucketName)
			httpHeader := http.Header{
				http.CanonicalHeaderKey("Content-Type"): []string{"application/xml"},
			}

			fakeServer.AppendHandlers(ghttp.CombineHandlers(
				ghttp.VerifyRequest("GET", fmt.Sprintf("/%s/", bucketName)),
				ghttp.RespondWithPtr(&statusCode, &responseBody, httpHeader),
			))
		})

		It("returns ok=true if able to connect and auth and it exists", func() {
			statusCode = http.StatusOK
			responseBody = `<?xml version="1.0" encoding="UTF-8"?><ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>x</ID><DisplayName>x</DisplayName></Owner><Buckets><Bucket><Name>bucket</Name><CreationDate>2015-06-11T16:50:43.000Z</CreationDate></Bucket></Buckets></ListAllMyBucketsResult>`

			ok, err := verifyBlobTarget()