MSP-2243 implement ldap integration

This commit is contained in:
d1slike committed 2023-10-18 13:24:50 +03:00
1 parent 051dea1674
commit cd04e996e1
20 files changed
+567 -184

No files matched your search

+21 -10
View File
@@ -5,6 +5,7 @@ import (
"testing"
"time"
"github.com/integration-system/isp-kit/bgjobx"
"github.com/integration-system/isp-kit/dbx"
"github.com/integration-system/isp-kit/test"
"github.com/integration-system/isp-kit/test/dbt"
@@ -12,7 +13,7 @@ import (
"msp-admin-service/conf"
"msp-admin-service/entity"
"msp-admin-service/repository"
"msp-admin-service/tests"
"msp-admin-service/service/inactive_worker"
)
func TestInactiveWorker(t *testing.T) {
@@ -21,16 +22,16 @@ func TestInactiveWorker(t *testing.T) {
test, require := test.New(t)
db := dbt.New(test, dbx.WithMigration("../migrations"))
userId := tests.InsertUser(db, entity.User{Email: "a@test"})
tests.InsertUser(db, entity.User{Email: "b@test"})
tests.InsertTokenEntity(db, entity.Token{
userId := InsertUser(db, entity.User{Email: "a@test"})
InsertUser(db, entity.User{Email: "b@test"})
InsertTokenEntity(db, entity.Token{
Id: 0,
Token: "123",
UserId: userId,
Status: entity.TokenStatusAllowed,
CreatedAt: time.Now().UTC().Add(-48 * time.Hour),
})
tests.InsertTokenEntity(db, entity.Token{
InsertTokenEntity(db, entity.Token{
Id: 0,
Token: "234",
UserId: userId,
@@ -38,11 +39,21 @@ func TestInactiveWorker(t *testing.T) {
CreatedAt: time.Now().UTC().Add(-5 * 24 * time.Hour),
})
worker := assembly.NewLocator(test.Logger(), nil, db).
Config(context.Background(), conf.Remote{BlockInactiveWorker: conf.BlockInactiveWorker{DaysThreshold: 1}}).
InactiveBlocker
worker.Do(context.Background())
time.Sleep(1 * time.Second)
config := assembly.NewLocator(test.Logger(), nil, db).
Config(context.Background(), emptyLdap, conf.Remote{
BlockInactiveWorker: conf.BlockInactiveWorker{
DaysThreshold: 1,
RunIntervalInMinutes: 60,
},
})
bgjobCli := bgjobx.NewClient(db, test.Logger())
assembly.JobPollInterval = 1 * time.Second
err := bgjobCli.Upgrade(context.Background(), config.BgJobCfg)
require.NoError(err)
err = inactive_worker.EnqueueSeedJob(context.Background(), bgjobCli)
require.NoError(err)
time.Sleep(5 * time.Second)
user, err := repository.NewUser(db).GetUserById(context.Background(), userId)
require.NoError(err)