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


Golang FakeConnMetadata.UserReturns方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry-incubator/diego-ssh/test_helpers/fake_ssh.FakeConnMetadata.UserReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeConnMetadata.UserReturns方法的具體用法?Golang FakeConnMetadata.UserReturns怎麽用?Golang FakeConnMetadata.UserReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry-incubator/diego-ssh/test_helpers/fake_ssh.FakeConnMetadata的用法示例。


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

示例1:

			password    []byte
			authErr     error
		)

		BeforeEach(func() {
			permissions = nil
			password = []byte{}
		})

		JustBeforeEach(func() {
			permissions, authErr = authenticator.Authenticate(metadata, password)
		})

		Context("when the user name matches the user regex and valid credentials are provided", func() {
			BeforeEach(func() {
				metadata.UserReturns("diego:some-guid/0")
				password = []byte("some-user:some-password")
			})

			It("authenticates the password against the provided user:password", func() {
				Expect(authErr).NotTo(HaveOccurred())
			})

			It("builds permissions for the requested process", func() {
				Expect(permissionsBuilder.BuildCallCount()).To(Equal(1))
				guid, index, metadata := permissionsBuilder.BuildArgsForCall(0)
				Expect(guid).To(Equal("some-guid"))
				Expect(index).To(Equal(0))
				Expect(metadata).To(Equal(metadata))
			})
		})
開發者ID:swisscom,項目名稱:diego-ssh,代碼行數:31,代碼來源:diego_proxy_authenticator_test.go

示例2:

		Context("when one or more authenticators are specified", func() {
			var (
				authenticatorOne *fake_authenticators.FakePasswordAuthenticator
				authenticatorTwo *fake_authenticators.FakePasswordAuthenticator
			)

			BeforeEach(func() {
				authenticatorOne = &fake_authenticators.FakePasswordAuthenticator{}
				authenticatorTwo = &fake_authenticators.FakePasswordAuthenticator{}
				authenticatorMap["one"] = authenticatorOne
				authenticatorMap["two"] = authenticatorOne
			})

			Context("and the users realm matches the first authenticator", func() {
				BeforeEach(func() {
					metadata.UserReturns("one:garbage")
				})

				Context("and the authenticator successfully authenticates", func() {
					var permissions *ssh.Permissions

					BeforeEach(func() {
						permissions = &ssh.Permissions{}
						authenticatorOne.AuthenticateReturns(permissions, nil)
					})

					It("succeeds to authenticate", func() {
						perms, err := authenticator.Authenticate(metadata, password)

						Expect(err).NotTo(HaveOccurred())
						Expect(perms).To(Equal(permissions))
開發者ID:sykesm,項目名稱:diego-ssh,代碼行數:31,代碼來源:composite_authenticator_test.go

示例3:

		})
	})

	Describe("Authenticate", func() {
		const expectedOneTimeCode = "abc123"

		var (
			uaaTokenResponse     *authenticators.UAAAuthTokenResponse
			uaaTokenResponseCode int

			sshAccessResponse     *authenticators.AppSSHResponse
			sshAccessResponseCode int
		)

		BeforeEach(func() {
			metadata.UserReturns("cf:app-guid/1")
			password = []byte(expectedOneTimeCode)

			uaaTokenResponseCode = http.StatusOK
			uaaTokenResponse = &authenticators.UAAAuthTokenResponse{
				AccessToken: "exchanged-token",
				TokenType:   "bearer",
			}

			fakeUAA.AppendHandlers(
				ghttp.CombineHandlers(
					ghttp.VerifyRequest("POST", "/oauth/token"),
					ghttp.VerifyBasicAuth("diego-ssh", "diego-ssh-secret-$\"^&'"),
					ghttp.VerifyFormKV("grant_type", "authorization_code"),
					ghttp.VerifyFormKV("code", expectedOneTimeCode),
					ghttp.RespondWithJSONEncodedPtr(&uaaTokenResponseCode, uaaTokenResponse),
開發者ID:benjaminharnett,項目名稱:diego-ssh,代碼行數:31,代碼來源:cf_authenticator_test.go


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