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

Side by Side Diff: mojo/shell/tests/connect/connect_unittest.cc

Issue 1811483003: Remove support for Root identity singletons and rely on the all_users bit to be set. + test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@54login2
Patch Set: Created 4 years, 9 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 Identity result_identity; 345 Identity result_identity;
346 { 346 {
347 base::RunLoop loop; 347 base::RunLoop loop;
348 client_process_test->LaunchAndConnectToProcess( 348 client_process_test->LaunchAndConnectToProcess(
349 base::Bind(&ReceiveConnectionResult, &result, &result_identity, &loop)); 349 base::Bind(&ReceiveConnectionResult, &result, &result_identity, &loop));
350 loop.Run(); 350 loop.Run();
351 } 351 }
352 EXPECT_EQ(shell::mojom::ConnectResult::ACCESS_DENIED, result); 352 EXPECT_EQ(shell::mojom::ConnectResult::ACCESS_DENIED, result);
353 } 353 }
354 354
355 // Verifies that a client with the "all_users" capability class can receive
356 // connections from clients run as other users.
357 TEST_F(ConnectTest, AllUsersSingleton) {
358 // Connect to an instance with an explicitly different user_id.
359 const std::string singleton_userid = base::GenerateGUID();
360 Connector::ConnectParams params(Identity(kTestAppName, singleton_userid));
361 scoped_ptr<Connection> connection = connector()->Connect(&params);
362 {
363 base::RunLoop loop;
364 connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop));
365 loop.Run();
366 EXPECT_EQ(connection->GetRemoteIdentity().user_id(), singleton_userid);
367 }
368 // This connects using the current client's user_id, but should be bound to
369 // the instance run as |singleton_userid|.
370 scoped_ptr<Connection> inherit_connection =
371 connector()->Connect(kTestAppName);
372 {
373 base::RunLoop loop;
374 inherit_connection->AddConnectionCompletedClosure(
375 base::Bind(&QuitLoop, &loop));
376 loop.Run();
377 EXPECT_EQ(connection->GetRemoteIdentity().user_id(), singleton_userid);
378 }
379 }
380
355 // Tests that we can expose an interface to targets on outbound connections. 381 // Tests that we can expose an interface to targets on outbound connections.
356 TEST_F(ConnectTest, LocalInterface) { 382 TEST_F(ConnectTest, LocalInterface) {
357 // Connect to a standalone application. 383 // Connect to a standalone application.
358 { 384 {
359 test::mojom::ConnectTestServicePtr service; 385 test::mojom::ConnectTestServicePtr service;
360 scoped_ptr<Connection> connection = connector()->Connect(kTestAppName); 386 scoped_ptr<Connection> connection = connector()->Connect(kTestAppName);
361 connection->GetInterface(&service); 387 connection->GetInterface(&service);
362 connection->AddInterface<test::mojom::ExposedInterface>(this); 388 connection->AddInterface<test::mojom::ExposedInterface>(this);
363 389
364 uint32_t remote_id = shell::mojom::kInvalidInstanceID; 390 uint32_t remote_id = shell::mojom::kInvalidInstanceID;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 CompareConnectionState( 437 CompareConnectionState(
412 kTestAppAName, test_name(), test_userid(), test_instance_id(), 438 kTestAppAName, test_name(), test_userid(), test_instance_id(),
413 kTestAppAName, connection->GetRemoteIdentity().user_id(), remote_id); 439 kTestAppAName, connection->GetRemoteIdentity().user_id(), remote_id);
414 } 440 }
415 441
416 } 442 }
417 } 443 }
418 444
419 } // namespace shell 445 } // namespace shell
420 } // namespace mojo 446 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/tests/connect/connect_test_app_manifest.json ('k') | mojo/shell/tests/connect/connect_unittests_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698