mirror of
https://github.com/kopia/kopia.git
synced 2026-01-03 03:57:49 -05:00
- removed repo.OpenAPIServer() which was only needed for testability - introduced servertesting package to replace it
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package server_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/kopia/kopia/internal/apiclient"
|
|
"github.com/kopia/kopia/internal/repotesting"
|
|
"github.com/kopia/kopia/internal/serverapi"
|
|
"github.com/kopia/kopia/internal/servertesting"
|
|
"github.com/kopia/kopia/internal/testutil"
|
|
)
|
|
|
|
func TestPathsAPI(t *testing.T) {
|
|
ctx, env := repotesting.NewEnvironment(t, repotesting.FormatNotImportant)
|
|
srvInfo := servertesting.StartServer(t, env, false)
|
|
|
|
cli, err := apiclient.NewKopiaAPIClient(apiclient.Options{
|
|
BaseURL: srvInfo.BaseURL,
|
|
TrustedServerCertificateFingerprint: srvInfo.TrustedServerCertificateFingerprint,
|
|
Username: servertesting.TestUIUsername,
|
|
Password: servertesting.TestUIPassword,
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
require.NoError(t, cli.FetchCSRFTokenForTesting(ctx))
|
|
|
|
dir0 := testutil.TempDirectory(t)
|
|
|
|
req := &serverapi.ResolvePathRequest{
|
|
Path: dir0,
|
|
}
|
|
resp := &serverapi.ResolvePathResponse{}
|
|
require.NoError(t, cli.Post(ctx, "paths/resolve", req, resp))
|
|
|
|
require.Equal(t, env.LocalPathSourceInfo(dir0), resp.SourceInfo)
|
|
}
|