OLD | NEW |
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 Loading... |
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(DWORD{ERROR_SUCCESS}, token.Init(anonymous_token.GetHandle())); |
| 654 token.SetLockdownDefaultDacl(); |
| 655 |
| 656 base::win::ScopedHandle handle; |
| 657 ASSERT_EQ(DWORD{ERROR_SUCCESS}, token.GetRestrictedToken(&handle)); |
| 658 } |
| 659 |
643 } // namespace sandbox | 660 } // namespace sandbox |
OLD | NEW |