MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / NewSignatureTest

Function NewSignatureTest

oauthproxy_test.go:1544–1588  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1542}
1543
1544func NewSignatureTest() (*SignatureTest, error) {
1545 opts := baseTestOptions()
1546 opts.EmailDomains = []string{"acm.org"}
1547
1548 authenticator := &SignatureAuthenticator{}
1549 upstreamServer := httptest.NewServer(
1550 http.HandlerFunc(authenticator.Authenticate))
1551 upstreamURL, err := url.Parse(upstreamServer.URL)
1552 if err != nil {
1553 return nil, err
1554 }
1555 opts.UpstreamServers = options.UpstreamConfig{
1556 Upstreams: []options.Upstream{
1557 {
1558 ID: upstreamServer.URL,
1559 Path: "/",
1560 URI: upstreamServer.URL,
1561 },
1562 },
1563 }
1564
1565 providerHandler := func(w http.ResponseWriter, r *http.Request) {
1566 _, err := w.Write([]byte(`{"access_token": "my_auth_token"}`))
1567 if err != nil {
1568 panic(err)
1569 }
1570 }
1571 provider := httptest.NewServer(http.HandlerFunc(providerHandler))
1572 providerURL, err := url.Parse(provider.URL)
1573 if err != nil {
1574 return nil, err
1575 }
1576 testProvider := NewTestProvider(providerURL, "mbland@acm.org")
1577
1578 return &SignatureTest{
1579 opts,
1580 upstreamServer,
1581 upstreamURL.Host,
1582 provider,
1583 make(http.Header),
1584 httptest.NewRecorder(),
1585 authenticator,
1586 testProvider,
1587 }, nil
1588}
1589
1590func (st *SignatureTest) Close() {
1591 st.provider.Close()

Callers 1

TestRequestSignatureFunction · 0.85

Calls 3

baseTestOptionsFunction · 0.85
NewTestProviderFunction · 0.85
WriteMethod · 0.45

Tested by

no test coverage detected