-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathissuer_test.go
58 lines (47 loc) · 1.23 KB
/
issuer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package uaa_test
import (
"net/http"
"github.com/cloudfoundry-community/go-uaa"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"
)
var _ = Describe("Issuer", func() {
var (
server *ghttp.Server
api *uaa.API
)
BeforeEach(func() {
server = ghttp.NewServer()
server.AppendHandlers(ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/.well-known/openid-configuration"),
ghttp.RespondWithJSONEncoded(http.StatusOK, &uaa.OpenIDConfig{Issuer: "issuer"}),
))
target := server.URL()
var err error
api, err = uaa.New(target, uaa.WithNoAuthentication())
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
server.Close()
})
It("return the issuer", func() {
issuer, err := api.Issuer()
Expect(err).NotTo(HaveOccurred())
Expect(issuer).To(Equal("issuer"))
})
Context("when the server returns a non-200 status code", func() {
BeforeEach(func() {
server.Reset()
server.AppendHandlers(
ghttp.VerifyRequest("GET", "/.well-known/openid-configuration"),
ghttp.RespondWith(http.StatusInternalServerError, nil),
)
})
It("returns an error", func() {
issuer, err := api.Issuer()
Expect(err).To(HaveOccurred())
Expect(issuer).To(Equal(""))
})
})
})