2022-02-05 18:24:51 -06:00
|
|
|
package coderd_test
|
|
|
|
|
|
|
|
|
|
import (
|
2022-04-07 12:18:58 -05:00
|
|
|
"context"
|
2022-02-05 18:24:51 -06:00
|
|
|
"testing"
|
|
|
|
|
|
2022-04-07 12:18:58 -05:00
|
|
|
"github.com/stretchr/testify/require"
|
2022-05-17 13:43:19 -05:00
|
|
|
"go.uber.org/goleak"
|
2022-04-07 12:18:58 -05:00
|
|
|
|
|
|
|
|
"github.com/coder/coder/buildinfo"
|
|
|
|
|
"github.com/coder/coder/coderd/coderdtest"
|
2022-08-01 15:45:05 +03:00
|
|
|
"github.com/coder/coder/testutil"
|
2022-02-05 18:24:51 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
|
goleak.VerifyTestMain(m)
|
|
|
|
|
}
|
2022-04-07 12:18:58 -05:00
|
|
|
|
|
|
|
|
func TestBuildInfo(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
client := coderdtest.New(t, nil)
|
2022-08-09 20:17:00 +03:00
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
buildInfo, err := client.BuildInfo(ctx)
|
2022-04-07 12:18:58 -05:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.Equal(t, buildinfo.ExternalURL(), buildInfo.ExternalURL, "external URL")
|
|
|
|
|
require.Equal(t, buildinfo.Version(), buildInfo.Version, "version")
|
|
|
|
|
}
|
2022-05-17 13:43:19 -05:00
|
|
|
|
|
|
|
|
// TestAuthorizeAllEndpoints will check `authorize` is called on every endpoint registered.
|
|
|
|
|
func TestAuthorizeAllEndpoints(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
2022-08-09 20:17:00 +03:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
|
|
|
|
defer cancel()
|
2022-08-24 12:05:46 -07:00
|
|
|
a := coderdtest.NewAuthTester(ctx, t, nil)
|
|
|
|
|
skipRoutes, assertRoute := coderdtest.AGPLRoutes(a)
|
|
|
|
|
a.Test(ctx, assertRoute, skipRoutes)
|
2022-05-17 13:43:19 -05:00
|
|
|
}
|