mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-05-10 14:28:12 +00:00
tests: fix service tests
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
package service_test
|
package service_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -10,6 +12,7 @@ import (
|
|||||||
"github.com/tinyauthapp/tinyauth/internal/model"
|
"github.com/tinyauthapp/tinyauth/internal/model"
|
||||||
"github.com/tinyauthapp/tinyauth/internal/repository"
|
"github.com/tinyauthapp/tinyauth/internal/repository"
|
||||||
"github.com/tinyauthapp/tinyauth/internal/service"
|
"github.com/tinyauthapp/tinyauth/internal/service"
|
||||||
|
"github.com/tinyauthapp/tinyauth/internal/utils/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTestUser() repository.OidcUserinfo {
|
func newTestUser() repository.OidcUserinfo {
|
||||||
@@ -48,13 +51,29 @@ func newTestUser() repository.OidcUserinfo {
|
|||||||
|
|
||||||
func TestCompileUserinfo(t *testing.T) {
|
func TestCompileUserinfo(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
svc := service.NewOIDCService(service.OIDCServiceConfig{
|
|
||||||
|
cfg := model.Config{
|
||||||
|
OIDC: model.OIDCConfig{
|
||||||
PrivateKeyPath: dir + "/key.pem",
|
PrivateKeyPath: dir + "/key.pem",
|
||||||
PublicKeyPath: dir + "/key.pub",
|
PublicKeyPath: dir + "/key.pub",
|
||||||
Issuer: "https://tinyauth.example.com",
|
},
|
||||||
|
Auth: model.AuthConfig{
|
||||||
SessionExpiry: 3600,
|
SessionExpiry: 3600,
|
||||||
}, nil)
|
},
|
||||||
require.NoError(t, svc.Init())
|
}
|
||||||
|
|
||||||
|
runtime := model.RuntimeConfig{
|
||||||
|
AppURL: "https://tinyauth.example.com",
|
||||||
|
}
|
||||||
|
|
||||||
|
log := logger.NewLogger().WithTestConfig()
|
||||||
|
log.Init()
|
||||||
|
|
||||||
|
ctx := context.TODO()
|
||||||
|
wg := &sync.WaitGroup{}
|
||||||
|
|
||||||
|
svc, err := service.NewOIDCService(log, cfg, runtime, nil, ctx, wg)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
description string
|
description string
|
||||||
|
|||||||
Reference in New Issue
Block a user