-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_test.go
30 lines (23 loc) · 1.17 KB
/
main_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
package main
import (
"testing"
"github.com/aws/aws-lambda-go/events"
"github.com/stretchr/testify/require"
)
func TestMain_HandleRequest(t *testing.T) {
ret, err := handleRequest(nil, events.APIGatewayProxyRequest{Path: "/cothority/"})
require.NoError(t, err)
require.Contains(t, ret.Body, `<meta http-equiv="refresh" content="0; url=https://godoc.org/go.dedis.ch/cothority/">`)
ret, err = handleRequest(nil, events.APIGatewayProxyRequest{Path: "/cothority/v3/blscosi"})
require.NoError(t, err)
require.Contains(t, ret.Body, `<meta http-equiv="refresh" content="0; url=https://godoc.org/go.dedis.ch/cothority/blscosi">`)
ret, err = handleRequest(nil, events.APIGatewayProxyRequest{Path: "/abc"})
require.NoError(t, err)
require.Contains(t, ret.Body, "<h1>404 Page Not Found</h1>")
ret, err = handleRequest(nil, events.APIGatewayProxyRequest{Path: "///"})
require.NoError(t, err)
require.Contains(t, ret.Body, `<meta http-equiv="refresh" content="0; url=https://dedis.epfl.ch">`)
ret, err = handleRequest(nil, events.APIGatewayProxyRequest{Path: ""})
require.NoError(t, err)
require.Contains(t, ret.Body, `<meta http-equiv="refresh" content="0; url=https://dedis.epfl.ch">`)
}