forked from baron/baron-sso
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"baron-sso-backend/internal/service"
|
|
"testing"
|
|
)
|
|
|
|
func TestClassifyWorksmobileAlignFromWorksAllowsDomainOnlyEmailMismatch(t *testing.T) {
|
|
item := service.WorksmobileComparisonItem{
|
|
BaronEmail: "user@typo.example.com",
|
|
WorksmobileEmail: "user@example.com",
|
|
}
|
|
|
|
status, ok := classifyWorksmobileAlignFromWorks(item)
|
|
|
|
if !ok {
|
|
t.Fatalf("expected domain-only email mismatch to be alignable, status=%s", status)
|
|
}
|
|
if status != "updated" {
|
|
t.Fatalf("expected updated status, got %s", status)
|
|
}
|
|
}
|
|
|
|
func TestClassifyWorksmobileAlignFromWorksSkipsLocalPartChange(t *testing.T) {
|
|
item := service.WorksmobileComparisonItem{
|
|
BaronEmail: "old@example.com",
|
|
WorksmobileEmail: "new@example.com",
|
|
}
|
|
|
|
status, ok := classifyWorksmobileAlignFromWorks(item)
|
|
|
|
if ok {
|
|
t.Fatalf("expected local-part change to be skipped")
|
|
}
|
|
if status != "skipped_email_local_part_changed" {
|
|
t.Fatalf("expected skipped_email_local_part_changed status, got %s", status)
|
|
}
|
|
}
|
|
|
|
func TestWorksmobileUserLevelPatchDomainIDPrefersLevelDomain(t *testing.T) {
|
|
payload := service.WorksmobileUserPayload{
|
|
DomainID: 300285955,
|
|
LevelDomainID: 300286337,
|
|
}
|
|
|
|
if got := worksmobileUserLevelPatchDomainID(payload); got != 300286337 {
|
|
t.Fatalf("expected level domain id, got %d", got)
|
|
}
|
|
}
|