コード例 #1
0
						commandRan := false
						cliApp.Commands = []cli.Command{
							cli.Command{
								Name: "print-a-unicorn",
								Action: func(ctx *cli.Context) {
									commandRan = true
								},
							},
						}

						err := cliApp.Run([]string{"ltc", "print-a-unicorn"})
						Expect(err).NotTo(HaveOccurred())

						Expect(commandRan).To(BeTrue())
						Expect(fakeTargetVerifier.VerifyTargetCallCount()).To(Equal(1))
						Expect(fakeTargetVerifier.VerifyTargetArgsForCall(0)).To(Equal("http://receptor.my-lattice.example.com"))
					})
				})

				Context("when we are unauthorized for the targeted receptor", func() {
					It("Prints an error message and does not execute the command", func() {
						fakeTargetVerifier.VerifyTargetReturns(true, false, nil)
						cliConfig.SetTarget("my-borked-lattice.example.com")
						Expect(cliConfig.Save()).To(Succeed())

						commandRan := false
						cliApp.Commands = []cli.Command{
							cli.Command{
								Name:   "print-a-unicorn",
								Action: func(ctx *cli.Context) { commandRan = true },
							},
コード例 #2
0
					Expect(string(outputBuffer.Contents())).To(BeEmpty())
				})
			})
		})

		Context("when initially connecting to the receptor without authentication", func() {
			BeforeEach(func() {
				fakeTargetVerifier.VerifyTargetReturns(true, true, nil)
				fakeBlobStoreVerifier.VerifyReturns(true, nil)
			})

			It("saves the new receptor target", func() {
				test_helpers.ExecuteCommandWithArgs(targetCommand, []string{"myapi.com"})

				Expect(fakeTargetVerifier.VerifyTargetCallCount()).To(Equal(1))
				Expect(fakeTargetVerifier.VerifyTargetArgsForCall(0)).To(Equal("http://receptor.myapi.com"))

				newConfig := config_package.New(configPersister)
				Expect(newConfig.Load()).To(Succeed())
				Expect(newConfig.Receptor()).To(Equal("http://receptor.myapi.com"))
			})

			It("clears out existing saved target credentials", func() {
				test_helpers.ExecuteCommandWithArgs(targetCommand, []string{"myapi.com"})

				Expect(fakeTargetVerifier.VerifyTargetCallCount()).To(Equal(1))
				Expect(fakeTargetVerifier.VerifyTargetArgsForCall(0)).To(Equal("http://receptor.myapi.com"))
			})

			It("saves the new blob store target", func() {
				fakeBlobStoreVerifier.VerifyReturns(true, nil)