mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
test(gui-client): add unit test for the elevation check (#6238)
This will always be elevated in CI, so just check that it doesn't crash. This came up during debugging while I was offline, and I just want to make CI check for regressions, since there's a lot of `unsafe` code in the Windows impl
This commit is contained in:
@@ -112,8 +112,20 @@ mod imp {
|
||||
impl Drop for ProcessToken {
|
||||
fn drop(&mut self) {
|
||||
// SAFETY: We got `inner` from `OpenProcessToken` and didn't mutate it after that.
|
||||
// Closing a pseudo-handle is a harmless no-op, though this is a real handle.
|
||||
// <https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentprocess>
|
||||
// > The pseudo handle need not be closed when it is no longer needed. Calling the CloseHandle function with a pseudo handle has no effect. If the pseudo handle is duplicated by DuplicateHandle, the duplicate handle must be closed.
|
||||
unsafe { CloseHandle(self.inner) }.expect("`CloseHandle` should always succeed");
|
||||
self.inner = HANDLE::default();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// Make sure it doesn't crash
|
||||
#[test]
|
||||
fn is_normal_user() {
|
||||
super::is_normal_user().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user