summaryrefslogtreecommitdiffstats
path: root/mojo/shell/tests/connect
diff options
context:
space:
mode:
Diffstat (limited to 'mojo/shell/tests/connect')
-rw-r--r--mojo/shell/tests/connect/connect_test_app_manifest.json2
-rw-r--r--mojo/shell/tests/connect/connect_unittest.cc26
-rw-r--r--mojo/shell/tests/connect/connect_unittests_manifest.json2
3 files changed, 28 insertions, 2 deletions
diff --git a/mojo/shell/tests/connect/connect_test_app_manifest.json b/mojo/shell/tests/connect/connect_test_app_manifest.json
index 7c45922..93b9782 100644
--- a/mojo/shell/tests/connect/connect_test_app_manifest.json
+++ b/mojo/shell/tests/connect/connect_test_app_manifest.json
@@ -9,7 +9,7 @@
"classes": [ "class" ],
"interfaces": ["mojo::shell::test::mojom::ConnectTestService"]
},
- "mojo:shell": { "classes": [ "user_id" ] }
+ "mojo:shell": { "classes": [ "user_id", "all_users" ] }
}
}
}
diff --git a/mojo/shell/tests/connect/connect_unittest.cc b/mojo/shell/tests/connect/connect_unittest.cc
index 8dd65ce..9cfb0a7 100644
--- a/mojo/shell/tests/connect/connect_unittest.cc
+++ b/mojo/shell/tests/connect/connect_unittest.cc
@@ -352,6 +352,32 @@ TEST_F(ConnectTest, ConnectToClientProcess_Blocked) {
EXPECT_EQ(shell::mojom::ConnectResult::ACCESS_DENIED, result);
}
+// Verifies that a client with the "all_users" capability class can receive
+// connections from clients run as other users.
+TEST_F(ConnectTest, AllUsersSingleton) {
+ // Connect to an instance with an explicitly different user_id.
+ const std::string singleton_userid = base::GenerateGUID();
+ Connector::ConnectParams params(Identity(kTestAppName, singleton_userid));
+ scoped_ptr<Connection> connection = connector()->Connect(&params);
+ {
+ base::RunLoop loop;
+ connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop));
+ loop.Run();
+ EXPECT_EQ(connection->GetRemoteIdentity().user_id(), singleton_userid);
+ }
+ // This connects using the current client's user_id, but should be bound to
+ // the instance run as |singleton_userid|.
+ scoped_ptr<Connection> inherit_connection =
+ connector()->Connect(kTestAppName);
+ {
+ base::RunLoop loop;
+ inherit_connection->AddConnectionCompletedClosure(
+ base::Bind(&QuitLoop, &loop));
+ loop.Run();
+ EXPECT_EQ(connection->GetRemoteIdentity().user_id(), singleton_userid);
+ }
+}
+
// Tests that we can expose an interface to targets on outbound connections.
TEST_F(ConnectTest, LocalInterface) {
// Connect to a standalone application.
diff --git a/mojo/shell/tests/connect/connect_unittests_manifest.json b/mojo/shell/tests/connect/connect_unittests_manifest.json
index e0b99ce..ea650b1 100644
--- a/mojo/shell/tests/connect/connect_unittests_manifest.json
+++ b/mojo/shell/tests/connect/connect_unittests_manifest.json
@@ -22,7 +22,7 @@
"mojo::shell::test::mojom::UserIdTest"
]
},
- "mojo:shell": { "classes": [ "instance_name" ] }
+ "mojo:shell": { "classes": [ "instance_name", "user_id" ] }
}
}
}