当前位置: 首页>>代码示例>>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;未经允许,请勿转载。