advapi32/tests: Test the type and impersonation level of a linked token.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-06-30 00:01:05 -05:00 committed by Alexandre Julliard
parent 17716bc7f3
commit 2cbed06609
1 changed files with 21 additions and 1 deletions

View File

@ -8139,6 +8139,12 @@ static void test_elevation(void)
ret = GetTokenInformation(linked.LinkedToken, TokenElevation, &elevation, sizeof(elevation), &size);
ok(ret, "got error %u\n", GetLastError());
ok(elevation.TokenIsElevated == TRUE, "got elevation %#x\n", elevation.TokenIsElevated);
ret = GetTokenInformation(linked.LinkedToken, TokenType, &type, sizeof(type), &size);
ok(ret, "got error %u\n", GetLastError());
ok(type == TokenImpersonation, "got type %#x\n", type);
ret = GetTokenInformation(linked.LinkedToken, TokenImpersonationLevel, &type, sizeof(type), &size);
ok(ret, "got error %u\n", GetLastError());
ok(type == SecurityIdentification, "got impersonation level %#x\n", type);
/* Asking for the linked token again gives us a different token. */
ret = GetTokenInformation(token, TokenLinkedToken, &linked2, sizeof(linked2), &size);
@ -8194,6 +8200,12 @@ static void test_elevation(void)
ret = GetTokenInformation(linked.LinkedToken, TokenElevation, &elevation, sizeof(elevation), &size);
ok(ret, "got error %u\n", GetLastError());
ok(elevation.TokenIsElevated == FALSE, "got elevation %#x\n", elevation.TokenIsElevated);
ret = GetTokenInformation(linked.LinkedToken, TokenType, &type, sizeof(type), &size);
ok(ret, "got error %u\n", GetLastError());
todo_wine ok(type == TokenImpersonation, "got type %#x\n", type);
ret = GetTokenInformation(linked.LinkedToken, TokenImpersonationLevel, &type, sizeof(type), &size);
todo_wine ok(ret, "got error %u\n", GetLastError());
ok(type == SecurityIdentification, "got impersonation level %#x\n", type);
/* Asking for the linked token again gives us a different token. */
ret = GetTokenInformation(token, TokenLinkedToken, &linked2, sizeof(linked2), &size);
@ -8249,10 +8261,18 @@ static void test_elevation(void)
ret = GetTokenInformation(token2, TokenLinkedToken, &linked, sizeof(linked), &size);
ok(ret, "got error %u\n", GetLastError());
if (type == TokenElevationTypeDefault)
{
ok(!linked.LinkedToken, "expected no linked token\n");
ret = GetTokenInformation(linked.LinkedToken, TokenType, &type, sizeof(type), &size);
ok(ret, "got error %u\n", GetLastError());
ok(type == TokenImpersonation, "got type %#x\n", type);
ret = GetTokenInformation(linked.LinkedToken, TokenImpersonationLevel, &type, sizeof(type), &size);
ok(ret, "got error %u\n", GetLastError());
ok(type == SecurityIdentification, "got impersonation level %#x\n", type);
CloseHandle(linked.LinkedToken);
}
else
ok(!!linked.LinkedToken, "expected a linked token\n");
CloseHandle(linked.LinkedToken);
CloseHandle(token2);
ret = CreateRestrictedToken(token, 0, 0, NULL, 0, NULL, 0, NULL, &token2);