Context("when no authenticators are specified", func() { It("fails to authenticate", func() { _, err := authenticator.Authenticate(metadata, password) Expect(err).To(Equal(authenticators.InvalidCredentialsErr)) }) }) Context("when one or more authenticators are specified", func() { var ( authenticatorOne *fake_authenticators.FakePasswordAuthenticator authenticatorTwo *fake_authenticators.FakePasswordAuthenticator ) BeforeEach(func() { authenticatorOne = &fake_authenticators.FakePasswordAuthenticator{} authenticatorOne.UserRegexpReturns(regexp.MustCompile("one:.*")) authenticatorTwo = &fake_authenticators.FakePasswordAuthenticator{} authenticatorTwo.UserRegexpReturns(regexp.MustCompile("two:.*")) authens = []authenticators.PasswordAuthenticator{ authenticatorOne, authenticatorTwo, } }) Context("and the users realm matches the first authenticator", func() { BeforeEach(func() { metadata.UserReturns("one:garbage") })