當前位置: 首頁>>代碼示例>>Golang>>正文


Golang target_verifier.TargetVerifier類代碼示例

本文整理匯總了Golang中github.com/cloudfoundry-incubator/lattice/ltc/config/target_verifier.TargetVerifier的典型用法代碼示例。如果您正苦於以下問題:Golang TargetVerifier類的具體用法?Golang TargetVerifier怎麽用?Golang TargetVerifier使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TargetVerifier類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: MakeCliApp

func MakeCliApp(
	diegoVersion string,
	latticeVersion string,
	ltcConfigRoot string,
	exitHandler exit_handler.ExitHandler,
	config *config.Config,
	logger lager.Logger,
	receptorClientCreator receptor_client.Creator,
	targetVerifier target_verifier.TargetVerifier,
	cliStdout io.Writer,
) *cli.App {
	config.Load()
	app := cli.NewApp()
	app.Name = AppName
	app.Author = latticeCliAuthor
	app.Version = defaultVersion(diegoVersion, latticeVersion)
	app.Usage = LtcUsage
	app.Email = "[email protected]"

	ui := terminal.NewUI(os.Stdin, cliStdout, password_reader.NewPasswordReader(exitHandler))
	app.Writer = ui

	app.Before = func(context *cli.Context) error {
		args := context.Args()
		command := app.Command(args.First())

		if command == nil {
			return nil
		}

		if _, ok := nonTargetVerifiedCommandNames[command.Name]; ok || len(args) == 0 {
			return nil
		}

		if receptorUp, authorized, err := targetVerifier.VerifyTarget(config.Receptor()); !receptorUp {
			ui.SayLine(fmt.Sprintf("Error connecting to the receptor. Make sure your lattice target is set, and that lattice is up and running.\n\tUnderlying error: %s", err.Error()))
			return err
		} else if !authorized {
			ui.SayLine("Could not authenticate with the receptor. Please run ltc target with the correct credentials.")
			return errors.New("Could not authenticate with the receptor.")
		}
		return nil
	}

	app.Action = defaultAction
	app.CommandNotFound = func(c *cli.Context, command string) {
		ui.SayLine(fmt.Sprintf(unknownCommand, command))
		exitHandler.Exit(1)
	}
	app.Commands = cliCommands(ltcConfigRoot, exitHandler, config, logger, receptorClientCreator, targetVerifier, ui)
	return app
}
開發者ID:datachand,項目名稱:lattice,代碼行數:52,代碼來源:cli_app_factory.go

示例2:

	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/ghttp"

	config_package "github.com/cloudfoundry-incubator/lattice/ltc/config"
	"github.com/cloudfoundry-incubator/lattice/ltc/config/persister"
	"github.com/cloudfoundry-incubator/lattice/ltc/config/target_verifier"
	"github.com/cloudfoundry-incubator/receptor"
	"github.com/cloudfoundry-incubator/receptor/fake_receptor"
)

var _ = Describe("TargetVerifier", func() {
	Describe("VerifyBlobTarget", func() {
		var (
			config         *config_package.Config
			fakeServer     *ghttp.Server
			targetVerifier target_verifier.TargetVerifier
			statusCode     int
			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))
開發者ID:rajkumargithub,項目名稱:lattice,代碼行數:31,代碼來源:blob_target_verifier_test.go

示例3:

	"errors"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry-incubator/lattice/ltc/config/target_verifier"
	"github.com/cloudfoundry-incubator/lattice/ltc/receptor_client/fake_receptor_client_creator"
	"github.com/cloudfoundry-incubator/receptor"
	"github.com/cloudfoundry-incubator/receptor/fake_receptor"
)

var _ = Describe("TargetVerifier", func() {
	Describe("VerifyTarget", func() {
		var (
			fakeReceptorClient        *fake_receptor.FakeClient
			fakeReceptorClientCreator *fake_receptor_client_creator.FakeCreator
			targetVerifier            target_verifier.TargetVerifier
		)

		BeforeEach(func() {
			fakeReceptorClient = &fake_receptor.FakeClient{}
			fakeReceptorClientCreator = &fake_receptor_client_creator.FakeCreator{}
			fakeReceptorClientCreator.CreateReceptorClientReturns(fakeReceptorClient)
			targetVerifier = target_verifier.New(fakeReceptorClientCreator)
		})

		It("returns up=true, auth=true if the receptor does not return an error", func() {
			up, auth, err := targetVerifier.VerifyTarget("http://receptor.mylattice.com")
			Expect(err).NotTo(HaveOccurred())
			Expect(up).To(BeTrue())
			Expect(auth).To(BeTrue())
開發者ID:davidwadden,項目名稱:lattice-release,代碼行數:31,代碼來源:target_verifier_test.go

示例4:

	config_package "github.com/cloudfoundry-incubator/lattice/ltc/config"
)

var _ = Describe("TargetVerifier", func() {
	Describe("VerifyBlobTarget", func() {
		const (
			accessKey  = "V8GDQFR_VDOGM55IV8OH"
			secretKey  = "Wv_kltnl98hNWNdNwyQPYnFhK4gVPTxVS3NNMg=="
			bucketName = "BuCKeTHeaD"
		)

		var (
			config         *config_package.Config
			fakeServer     *ghttp.Server
			targetVerifier target_verifier.TargetVerifier
			statusCode     int
			responseBody   string
		)

		verifyBlobTarget := func() (bool, error) {
			return targetVerifier.VerifyBlobTarget(
				config.BlobTarget().TargetHost,
				config.BlobTarget().TargetPort,
				config.BlobTarget().AccessKey,
				config.BlobTarget().SecretKey,
				bucketName,
			)
		}

		BeforeEach(func() {
開發者ID:se77en,項目名稱:lattice,代碼行數:30,代碼來源:blob_target_verifier_test.go


注:本文中的github.com/cloudfoundry-incubator/lattice/ltc/config/target_verifier.TargetVerifier類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。