Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: sandbox/win/src/restricted_token_unittest.cc

Issue 2061703002: Fix for running Chrome under a service token. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unittest Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/win/src/acl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains unit tests for the RestrictedToken. 5 // This file contains unit tests for the RestrictedToken.
6 6
7 #define _ATL_NO_EXCEPTIONS 7 #define _ATL_NO_EXCEPTIONS
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <atlsecurity.h> 9 #include <atlsecurity.h>
10 #include <vector> 10 #include <vector>
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 } 633 }
634 634
635 // Checks the error code when the object is initialized twice. 635 // Checks the error code when the object is initialized twice.
636 TEST(RestrictedTokenTest, DoubleInit) { 636 TEST(RestrictedTokenTest, DoubleInit) {
637 RestrictedToken token; 637 RestrictedToken token;
638 ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL)); 638 ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS), token.Init(NULL));
639 639
640 ASSERT_EQ(static_cast<DWORD>(ERROR_ALREADY_INITIALIZED), token.Init(NULL)); 640 ASSERT_EQ(static_cast<DWORD>(ERROR_ALREADY_INITIALIZED), token.Init(NULL));
641 } 641 }
642 642
643 TEST(RestrictedTokenTest, LockdownDefaultDaclNoLogonSid) {
644 ATL::CAccessToken anonymous_token;
645 ASSERT_TRUE(::ImpersonateAnonymousToken(::GetCurrentThread()));
646 ASSERT_TRUE(anonymous_token.GetThreadToken(TOKEN_ALL_ACCESS));
647 ::RevertToSelf();
648 ATL::CSid logon_sid;
649 // Verify that the anonymous token doesn't have the logon sid.
650 ASSERT_FALSE(anonymous_token.GetLogonSid(&logon_sid));
651
652 RestrictedToken token;
653 ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS),
Will Harris 2016/06/13 16:22:36 nit, apparently the latest coding standard for cas
654 token.Init(anonymous_token.GetHandle()));
655 token.SetLockdownDefaultDacl();
656
657 base::win::ScopedHandle handle;
658 ASSERT_EQ(static_cast<DWORD>(ERROR_SUCCESS),
659 token.GetRestrictedToken(&handle));
660 }
661
643 } // namespace sandbox 662 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/acl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698