Commit dec4f92a authored by pneubeck@chromium.org's avatar pneubeck@chromium.org

More platformKeys api tests for the new system token.

All existing tests are run with the system token disabled and again with the system token enabled. Also are they applied once to the user token and once to the system token.

Additional tests ensure that the tokens don't affect each other.

BUG=210525,387606

Review URL: https://codereview.chromium.org/428223003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287227 0039d316-1c4b-4281-b951-d872f2087c98
parent 7a8f3d26
...@@ -185,32 +185,30 @@ class EnterprisePlatformKeysTest : public ExtensionApiTest { ...@@ -185,32 +185,30 @@ class EnterprisePlatformKeysTest : public ExtensionApiTest {
loop.Run(); loop.Run();
} }
{
base::RunLoop loop;
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
base::Bind(&EnterprisePlatformKeysTest::SetUpTestSystemSlot,
base::Unretained(this),
browser()->profile()->GetResourceContext(),
loop.QuitClosure()));
loop.Run();
}
SetPolicy(); SetPolicy();
} }
virtual void TearDownOnMainThread() OVERRIDE { void SetUpTestSystemSlot() {
base::RunLoop loop; base::RunLoop loop;
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::IO, content::BrowserThread::IO,
FROM_HERE, FROM_HERE,
base::Bind(&EnterprisePlatformKeysTest::TearDownTestSystemSlot, base::Bind(&EnterprisePlatformKeysTest::SetUpTestSystemSlotOnIO,
base::Unretained(this), base::Unretained(this),
browser()->profile()->GetResourceContext(),
loop.QuitClosure())); loop.QuitClosure()));
loop.Run(); loop.Run();
}
ExtensionApiTest::TearDownOnMainThread(); void TearDownTestSystemSlot() {
base::RunLoop loop;
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
base::Bind(&EnterprisePlatformKeysTest::TearDownTestSystemSlotOnIO,
base::Unretained(this),
loop.QuitClosure()));
loop.Run();
} }
private: private:
...@@ -226,7 +224,7 @@ class EnterprisePlatformKeysTest : public ExtensionApiTest { ...@@ -226,7 +224,7 @@ class EnterprisePlatformKeysTest : public ExtensionApiTest {
done_callback.Run(); done_callback.Run();
} }
void SetUpTestSystemSlot(content::ResourceContext* context, void SetUpTestSystemSlotOnIO(content::ResourceContext* context,
const base::Closure& done_callback) { const base::Closure& done_callback) {
test_system_slot_.reset(new crypto::ScopedTestSystemNSSKeySlot()); test_system_slot_.reset(new crypto::ScopedTestSystemNSSKeySlot());
ASSERT_TRUE(test_system_slot_->ConstructedSuccessfully()); ASSERT_TRUE(test_system_slot_->ConstructedSuccessfully());
...@@ -241,7 +239,7 @@ class EnterprisePlatformKeysTest : public ExtensionApiTest { ...@@ -241,7 +239,7 @@ class EnterprisePlatformKeysTest : public ExtensionApiTest {
content::BrowserThread::UI, FROM_HERE, done_callback); content::BrowserThread::UI, FROM_HERE, done_callback);
} }
void TearDownTestSystemSlot(const base::Closure& done_callback) { void TearDownTestSystemSlotOnIO(const base::Closure& done_callback) {
test_system_slot_.reset(); test_system_slot_.reset();
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
...@@ -284,7 +282,17 @@ class EnterprisePlatformKeysTest : public ExtensionApiTest { ...@@ -284,7 +282,17 @@ class EnterprisePlatformKeysTest : public ExtensionApiTest {
} // namespace } // namespace
IN_PROC_BROWSER_TEST_F(EnterprisePlatformKeysTest, Basic) { IN_PROC_BROWSER_TEST_F(EnterprisePlatformKeysTest, SystemTokenEnabled) {
SetUpTestSystemSlot();
ASSERT_TRUE(RunExtensionSubtest(
"",
base::StringPrintf("chrome-extension://%s/basic.html?systemTokenEnabled",
kTestExtensionID)))
<< message_;
TearDownTestSystemSlot();
}
IN_PROC_BROWSER_TEST_F(EnterprisePlatformKeysTest, SystemTokenDisabled) {
ASSERT_TRUE(RunExtensionSubtest( ASSERT_TRUE(RunExtensionSubtest(
"", "",
base::StringPrintf("chrome-extension://%s/basic.html", kTestExtensionID))) base::StringPrintf("chrome-extension://%s/basic.html", kTestExtensionID)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment