2ff6e05ffc
Permit integration - part 1 * WIP permit integration * slim down build * Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/permit-integration-1 * omit swagger from auth * clean build * comment * part 1 completed this is the initial permitio parts and tests without integration. Also testing.md since we have a new test target `task test:permitio` * feature flag for no jwt validation * permit integration * fix ci unit tests * ci fix * build fix * fix home handler * fix redirect * test fix * update docs for auth
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package cognitoauth
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// TestNewPermitIOClient_UnitTest tests client creation without requiring PDP
|
|
func TestNewPermitIOClient_UnitTest(t *testing.T) {
|
|
logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelError}))
|
|
|
|
client := NewPermitIOClient("test-key", "http://localhost:7766", logger)
|
|
|
|
assert.NotNil(t, client)
|
|
assert.NotNil(t, client.client)
|
|
assert.Equal(t, logger, client.logger)
|
|
}
|
|
|
|
// TestCheckPermission_UnitTest tests the method signature and error handling
|
|
func TestCheckPermission_UnitTest(t *testing.T) {
|
|
logger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelError}))
|
|
|
|
// Create client with invalid URL to test error handling
|
|
client := NewPermitIOClient("test-key", "http://invalid-nonexistent-host:9999", logger)
|
|
|
|
// This should return an error because the host doesn't exist
|
|
permitted, err := client.CheckPermission("test-user", "GET", "/test")
|
|
|
|
// We expect an error and false permission
|
|
assert.Error(t, err)
|
|
assert.False(t, permitted)
|
|
}
|