BeforeEach(func() { metadata.UserReturns("diego:some-guid/0") password = []byte("cf-user:cf-password") }) It("fails the authentication", func() { Expect(authErr).To(MatchError("Invalid credentials")) }) }) }) Describe("UserRegexp", func() { var regexp *regexp.Regexp BeforeEach(func() { regexp = authenticator.UserRegexp() }) It("matches diego patterns", func() { Expect(regexp.MatchString("diego:guid/0")).To(BeTrue()) Expect(regexp.MatchString("diego:123-abc-def/00")).To(BeTrue()) Expect(regexp.MatchString("diego:guid/99")).To(BeTrue()) }) It("does not match other patterns", func() { Expect(regexp.MatchString("diego:some+guid/99")).To(BeFalse()) Expect(regexp.MatchString("diego:..\\/something/99")).To(BeFalse()) Expect(regexp.MatchString("diego:guid/")).To(BeFalse()) Expect(regexp.MatchString("diego:00")).To(BeFalse()) Expect(regexp.MatchString("diego:/00")).To(BeFalse()) Expect(regexp.MatchString("cf:guid/0")).To(BeFalse())