diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-05-01 07:56:25 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-05-01 07:56:25 -0600 |
commit | 9a2da81b11ad0064cca24ce7974827d032309369 (patch) | |
tree | 4313224dc089208423e78bffc3ec50833e35bcea /contrib/tlsauth/auth_test.go | |
parent | 21e2758145d100d74013060f7090d84679cae683 (diff) |
name change gus -> sliderule
Diffstat (limited to 'contrib/tlsauth/auth_test.go')
-rw-r--r-- | contrib/tlsauth/auth_test.go | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/contrib/tlsauth/auth_test.go b/contrib/tlsauth/auth_test.go index 3cbc106..2a95e1c 100644 --- a/contrib/tlsauth/auth_test.go +++ b/contrib/tlsauth/auth_test.go @@ -12,9 +12,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "tildegit.org/tjp/gus" - "tildegit.org/tjp/gus/contrib/tlsauth" - "tildegit.org/tjp/gus/gemini" + sr "tildegit.org/tjp/sliderule" + "tildegit.org/tjp/sliderule/contrib/tlsauth" + "tildegit.org/tjp/sliderule/gemini" ) func TestIdentify(t *testing.T) { @@ -24,7 +24,7 @@ func TestIdentify(t *testing.T) { server, client, clientCert := setup(t, "testdata/server.crt", "testdata/server.key", "testdata/client1.crt", "testdata/client1.key", - gus.HandlerFunc(func(_ context.Context, request *gus.Request) *gus.Response { + sr.HandlerFunc(func(_ context.Context, request *sr.Request) *sr.Response { invoked = true ident := tlsauth.Identity(request) @@ -51,20 +51,20 @@ func TestRequiredAuth(t *testing.T) { invoked1 := false invoked2 := false - handler1 := gus.HandlerFunc(func(_ context.Context, request *gus.Request) *gus.Response { + handler1 := sr.HandlerFunc(func(_ context.Context, request *sr.Request) *sr.Response { invoked1 = true return gemini.Success("", &bytes.Buffer{}) }) - handler2 := gus.HandlerFunc(func(_ context.Context, request *gus.Request) *gus.Response { + handler2 := sr.HandlerFunc(func(_ context.Context, request *sr.Request) *sr.Response { invoked2 = true return gemini.Success("", &bytes.Buffer{}) }) - authMiddleware := gus.Filter(tlsauth.RequiredAuth(tlsauth.Allow), nil) + authMiddleware := sr.Filter(tlsauth.RequiredAuth(tlsauth.Allow), nil) - handler1 = gus.Filter( - func(_ context.Context, req *gus.Request) bool { + handler1 = sr.Filter( + func(_ context.Context, req *sr.Request) bool { return strings.HasPrefix(req.Path, "/one") }, nil, @@ -74,7 +74,7 @@ func TestRequiredAuth(t *testing.T) { server, client, _ := setup(t, "testdata/server.crt", "testdata/server.key", "testdata/client1.crt", "testdata/client1.key", - gus.FallthroughHandler(handler1, handler2), + sr.FallthroughHandler(handler1, handler2), ) go func() { @@ -94,7 +94,7 @@ func TestOptionalAuth(t *testing.T) { invoked1 := false invoked2 := false - handler1 := gus.HandlerFunc(func(_ context.Context, request *gus.Request) *gus.Response { + handler1 := sr.HandlerFunc(func(_ context.Context, request *sr.Request) *sr.Response { if !strings.HasPrefix(request.Path, "/one") { return nil } @@ -103,13 +103,13 @@ func TestOptionalAuth(t *testing.T) { return gemini.Success("", &bytes.Buffer{}) }) - handler2 := gus.HandlerFunc(func(_ context.Context, request *gus.Request) *gus.Response { + handler2 := sr.HandlerFunc(func(_ context.Context, request *sr.Request) *sr.Response { invoked2 = true return gemini.Success("", &bytes.Buffer{}) }) - mw := gus.Filter(tlsauth.OptionalAuth(tlsauth.Reject), nil) - handler := gus.FallthroughHandler(mw(handler1), mw(handler2)) + mw := sr.Filter(tlsauth.OptionalAuth(tlsauth.Reject), nil) + handler := sr.FallthroughHandler(mw(handler1), mw(handler2)) server, client, _ := setup(t, "testdata/server.crt", "testdata/server.key", @@ -136,8 +136,8 @@ func setup( serverKeyPath string, clientCertPath string, clientKeyPath string, - handler gus.Handler, -) (gus.Server, gemini.Client, tls.Certificate) { + handler sr.Handler, +) (sr.Server, gemini.Client, tls.Certificate) { serverTLS, err := gemini.FileTLS(serverCertPath, serverKeyPath) require.Nil(t, err) @@ -159,7 +159,7 @@ func setup( func clientFor( t *testing.T, - server gus.Server, + server sr.Server, certPath string, keyPath string, ) (gemini.Client, tls.Certificate) { @@ -179,11 +179,11 @@ func clientFor( }), clientCert } -func requestPath(t *testing.T, client gemini.Client, server gus.Server, path string) *gus.Response { +func requestPath(t *testing.T, client gemini.Client, server sr.Server, path string) *sr.Response { u, err := url.Parse("gemini://" + server.Address() + path) require.Nil(t, err) - response, err := client.RoundTrip(&gus.Request{URL: u}) + response, err := client.RoundTrip(&sr.Request{URL: u}) require.Nil(t, err) return response |