mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 08:50:46 +00:00
Update azcosmos package
This commit is contained in:
@@ -2,13 +2,11 @@ package tests_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos"
|
||||
"github.com/pikami/cosmium/api/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -47,12 +45,7 @@ func Test_Authentication(t *testing.T) {
|
||||
azcosmos.DatabaseProperties{ID: testDatabaseName},
|
||||
&azcosmos.CreateDatabaseOptions{})
|
||||
|
||||
var respErr *azcore.ResponseError
|
||||
if errors.As(err, &respErr) {
|
||||
assert.Equal(t, respErr.StatusCode, http.StatusUnauthorized)
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
assert.Contains(t, err.Error(), "401 Unauthorized")
|
||||
})
|
||||
|
||||
t.Run("Should allow unauthorized requests to /_explorer", func(t *testing.T) {
|
||||
@@ -68,7 +61,7 @@ func Test_Authentication(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Authentication_Disabled(t *testing.T) {
|
||||
ts := runTestServerCustomConfig(config.ServerConfig{
|
||||
ts := runTestServerCustomConfig(&config.ServerConfig{
|
||||
AccountKey: config.DefaultAccountKey,
|
||||
ExplorerPath: "/tmp/nothing",
|
||||
ExplorerBaseUrlLocation: config.ExplorerBaseUrlLocation,
|
||||
|
||||
@@ -15,13 +15,15 @@ type TestServer struct {
|
||||
URL string
|
||||
}
|
||||
|
||||
func runTestServerCustomConfig(config config.ServerConfig) *TestServer {
|
||||
func runTestServerCustomConfig(config *config.ServerConfig) *TestServer {
|
||||
repository := repositories.NewDataRepository(repositories.RepositoryOptions{})
|
||||
|
||||
api := api.NewApiServer(repository, config)
|
||||
|
||||
server := httptest.NewServer(api.GetRouter())
|
||||
|
||||
config.DatabaseEndpoint = server.URL
|
||||
|
||||
return &TestServer{
|
||||
Server: server,
|
||||
Repository: repository,
|
||||
@@ -30,7 +32,7 @@ func runTestServerCustomConfig(config config.ServerConfig) *TestServer {
|
||||
}
|
||||
|
||||
func runTestServer() *TestServer {
|
||||
config := config.ServerConfig{
|
||||
config := &config.ServerConfig{
|
||||
AccountKey: config.DefaultAccountKey,
|
||||
ExplorerPath: "/tmp/nothing",
|
||||
ExplorerBaseUrlLocation: config.ExplorerBaseUrlLocation,
|
||||
|
||||
Reference in New Issue
Block a user