Update V8 to version 4.3.37.
[chromium-blink-merge.git] / sandbox / win / src / sid_unittest.cc
blob76d61e82f5b343f2db7189b9c77610c34d3faf5c
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file contains unit tests for the sid class.
7 #define _ATL_NO_EXCEPTIONS
8 #include <atlbase.h>
9 #include <atlsecurity.h>
11 #include "sandbox/win/src/sid.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace sandbox {
16 // Calls ::EqualSid. This function exists only to simplify the calls to
17 // ::EqualSid by removing the need to cast the input params.
18 BOOL EqualSid(const SID *sid1, const SID *sid2) {
19 return ::EqualSid(const_cast<SID*>(sid1), const_cast<SID*>(sid2));
22 // Tests the creation if a Sid
23 TEST(SidTest, Constructors) {
24 ATL::CSid sid_world = ATL::Sids::World();
25 SID *sid_world_pointer = const_cast<SID*>(sid_world.GetPSID());
27 // Check the SID* constructor
28 Sid sid_sid_star(sid_world_pointer);
29 ASSERT_TRUE(EqualSid(sid_world_pointer, sid_sid_star.GetPSID()));
31 // Check the copy constructor
32 Sid sid_copy(sid_sid_star);
33 ASSERT_TRUE(EqualSid(sid_world_pointer, sid_copy.GetPSID()));
35 // Note that the WELL_KNOWN_SID_TYPE constructor is tested in the GetPSID
36 // test.
39 // Tests the method GetPSID
40 TEST(SidTest, GetPSID) {
41 // Check for non-null result;
42 ASSERT_NE(static_cast<SID*>(NULL), Sid(::WinLocalSid).GetPSID());
43 ASSERT_NE(static_cast<SID*>(NULL), Sid(::WinCreatorOwnerSid).GetPSID());
44 ASSERT_NE(static_cast<SID*>(NULL), Sid(::WinBatchSid).GetPSID());
46 ASSERT_TRUE(EqualSid(Sid(::WinNullSid).GetPSID(),
47 ATL::Sids::Null().GetPSID()));
49 ASSERT_TRUE(EqualSid(Sid(::WinWorldSid).GetPSID(),
50 ATL::Sids::World().GetPSID()));
52 ASSERT_TRUE(EqualSid(Sid(::WinDialupSid).GetPSID(),
53 ATL::Sids::Dialup().GetPSID()));
55 ASSERT_TRUE(EqualSid(Sid(::WinNetworkSid).GetPSID(),
56 ATL::Sids::Network().GetPSID()));
58 ASSERT_TRUE(EqualSid(Sid(::WinBuiltinAdministratorsSid).GetPSID(),
59 ATL::Sids::Admins().GetPSID()));
61 ASSERT_TRUE(EqualSid(Sid(::WinBuiltinUsersSid).GetPSID(),
62 ATL::Sids::Users().GetPSID()));
64 ASSERT_TRUE(EqualSid(Sid(::WinBuiltinGuestsSid).GetPSID(),
65 ATL::Sids::Guests().GetPSID()));
67 ASSERT_TRUE(EqualSid(Sid(::WinProxySid).GetPSID(),
68 ATL::Sids::Proxy().GetPSID()));
71 } // namespace sandbox