feat: add comprehensive Pester and standalone E2E test suite (96 tests) and code audit report
This commit is contained in:
@@ -13,12 +13,13 @@ function Parse-MultiUserInput {
|
||||
param([string]$RawInput)
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($RawInput)) {
|
||||
return @()
|
||||
return ,@()
|
||||
}
|
||||
|
||||
# 쉼표, 세미콜론, 줄바꿈, 탭, 공백 등 모든 구분자로 분리
|
||||
$tokens = $RawInput -split "[\r\n,;\t]+" | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne "" }
|
||||
return @($tokens | Select-Object -Unique)
|
||||
$uniqueTokens = @($tokens | Select-Object -Unique)
|
||||
return ,$uniqueTokens
|
||||
}
|
||||
|
||||
function Resolve-UsersWithAmbiguityCheck {
|
||||
@@ -39,11 +40,28 @@ function Resolve-UsersWithAmbiguityCheck {
|
||||
[PSCustomObject]@{ SamAccountName = "swjung"; DisplayName = "정수원"; Department = "인사기획팀"; Title = "차장"; Mail = "swjung@corp.local"; EmpId = "EMP1006" }
|
||||
)
|
||||
|
||||
$pool = $allPool
|
||||
if ($Config -and $Config.ActiveDirectory -and [bool]$Config.ActiveDirectory.UseLive -and (Get-Command Get-ADUserList -ErrorAction SilentlyContinue)) {
|
||||
try {
|
||||
$liveUsers = Get-ADUserList -Config $Config
|
||||
if ($liveUsers -and $liveUsers.Count -gt 0) {
|
||||
$pool = $liveUsers
|
||||
}
|
||||
} catch {
|
||||
Write-Warning "Live AD 사용자 풀 조회 실패, 기본 풀을 사용합니다: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
$resolvedResults = [System.Collections.Generic.List[PSCustomObject]]::new()
|
||||
|
||||
foreach ($token in $Tokens) {
|
||||
foreach ($rawToken in $Tokens) {
|
||||
if ([string]::IsNullOrWhiteSpace($rawToken)) {
|
||||
continue
|
||||
}
|
||||
$token = $rawToken.Trim()
|
||||
|
||||
# 1. SamAccountName 정확 일치 우선 검색
|
||||
$matchById = @($allPool | Where-Object { $_.SamAccountName -ieq $token })
|
||||
$matchById = @($pool | Where-Object { $_.SamAccountName -ieq $token })
|
||||
if ($matchById.Count -eq 1) {
|
||||
$u = $matchById[0]
|
||||
$resolvedResults.Add([PSCustomObject]@{
|
||||
@@ -64,8 +82,11 @@ function Resolve-UsersWithAmbiguityCheck {
|
||||
continue
|
||||
}
|
||||
|
||||
# 2. 이름(DisplayName) 일치 검색 (동명이인 판정)
|
||||
$matchByName = @($allPool | Where-Object { $_.DisplayName -ieq $token -or $_.DisplayName -like "*$token*" })
|
||||
# 2. 이름(DisplayName) 일치 검색 (동명이인 판정 - 와일드카드 안전 처리)
|
||||
$matchByName = @($pool | Where-Object {
|
||||
$_.DisplayName -ieq $token -or
|
||||
($_.DisplayName -and ($_.DisplayName.IndexOf($token, [System.StringComparison]::OrdinalIgnoreCase) -ge 0))
|
||||
})
|
||||
if ($matchByName.Count -eq 1) {
|
||||
$u = $matchByName[0]
|
||||
$resolvedResults.Add([PSCustomObject]@{
|
||||
@@ -124,5 +145,5 @@ function Resolve-UsersWithAmbiguityCheck {
|
||||
}
|
||||
}
|
||||
|
||||
return $resolvedResults.ToArray()
|
||||
return ,$resolvedResults.ToArray()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user