feat: add comprehensive Pester and standalone E2E test suite (96 tests) and code audit report
This commit is contained in:
+14
-8
@@ -11,7 +11,7 @@ function Test-ADConnection {
|
||||
)
|
||||
|
||||
try {
|
||||
$protocol = if ($UseLdaps) { "LDAP://$DomainController:636" } else { "LDAP://$DomainController" }
|
||||
$protocol = if ($UseLdaps) { "LDAP://${DomainController}:636" } else { "LDAP://$DomainController" }
|
||||
$path = if ([string]::IsNullOrWhiteSpace($BaseOU)) { "$protocol/RootDSE" } else { "$protocol/$BaseOU" }
|
||||
|
||||
$entry = if ([string]::IsNullOrWhiteSpace($Username)) {
|
||||
@@ -21,7 +21,10 @@ function Test-ADConnection {
|
||||
}
|
||||
|
||||
# 바인딩 강제 테스트
|
||||
$null = $entry.NativeObject
|
||||
if ($null -eq $entry.NativeObject) {
|
||||
throw "Active Directory DC에 바인딩할 수 없습니다. (NativeObject null)"
|
||||
}
|
||||
$null = $entry.Guid
|
||||
return [PSCustomObject]@{
|
||||
Success = $true
|
||||
Message = "Active Directory DC ($DomainController) 연결 성공 (RootDSE 응답 확인)"
|
||||
@@ -52,7 +55,7 @@ function Get-ADUserList {
|
||||
$pass = $Config.ActiveDirectory.Password
|
||||
|
||||
try {
|
||||
$prefix = if ($useLdaps) { "LDAP://$dc:636" } else { "LDAP://$dc" }
|
||||
$prefix = if ($useLdaps) { "LDAP://${dc}:636" } else { "LDAP://$dc" }
|
||||
$rootPath = if ([string]::IsNullOrWhiteSpace($baseOu)) { $prefix } else { "$prefix/$baseOu" }
|
||||
|
||||
$rootEntry = if ([string]::IsNullOrWhiteSpace($user)) {
|
||||
@@ -102,7 +105,9 @@ function Get-ADUserList {
|
||||
if ($fileTime -gt 0) {
|
||||
$lastLogonStr = [DateTime]::FromFileTime($fileTime).ToString("yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
} catch {}
|
||||
} catch {
|
||||
Write-Verbose "lastLogonTimestamp 파싱 건너뜀: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
$userList.Add([PSCustomObject]@{
|
||||
@@ -201,7 +206,7 @@ function Reset-ADUserPassword {
|
||||
$pass = $Config.ActiveDirectory.Password
|
||||
|
||||
try {
|
||||
$rootPath = if ([string]::IsNullOrWhiteSpace($baseOu)) { "LDAP://$dc:636" } else { "LDAP://$dc:636/$baseOu" }
|
||||
$rootPath = if ([string]::IsNullOrWhiteSpace($baseOu)) { "LDAP://${dc}:636" } else { "LDAP://${dc}:636/$baseOu" }
|
||||
$rootEntry = if ([string]::IsNullOrWhiteSpace($user)) {
|
||||
New-Object System.DirectoryServices.DirectoryEntry($rootPath)
|
||||
} else {
|
||||
@@ -367,13 +372,14 @@ function Get-ADSampleUsers {
|
||||
)
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($Filter)) {
|
||||
return $users
|
||||
return ,$users
|
||||
} else {
|
||||
return @($users | Where-Object {
|
||||
$matched = @($users | Where-Object {
|
||||
$_.SamAccountName -like "*$Filter*" -or
|
||||
$_.DisplayName -like "*$Filter*" -or
|
||||
$_.Department -like "*$Filter*"
|
||||
})
|
||||
return ,$matched
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +448,7 @@ function New-ADSecurityGroupOnTargetDc {
|
||||
$user = $Config.ActiveDirectory.Username
|
||||
$pass = $Config.ActiveDirectory.Password
|
||||
$useLdaps = [bool]$Config.ActiveDirectory.UseLdaps
|
||||
$proto = if ($useLdaps) { "LDAP://$TargetDc:636" } else { "LDAP://$TargetDc" }
|
||||
$proto = if ($useLdaps) { "LDAP://${TargetDc}:636" } else { "LDAP://$TargetDc" }
|
||||
$ouPath = "$proto/$TargetOU"
|
||||
|
||||
$ouEntry = if ([string]::IsNullOrWhiteSpace($user)) {
|
||||
|
||||
Reference in New Issue
Block a user