1 // Copyright 2014 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.
4 #include "chrome/browser/chromeos/login/supervised/supervised_user_authentication.h"
6 #include "base/values.h"
7 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
8 #include "chromeos/login/auth/key.h"
9 #include "testing/gtest/include/gtest/gtest.h"
13 class SupervisedUserAuthenticationTest : public testing::Test {
15 SupervisedUserAuthenticationTest();
16 virtual ~SupervisedUserAuthenticationTest();
19 virtual void SetUp() OVERRIDE;
20 virtual void TearDown() OVERRIDE;
22 DISALLOW_COPY_AND_ASSIGN(SupervisedUserAuthenticationTest);
25 SupervisedUserAuthenticationTest::SupervisedUserAuthenticationTest() {}
27 SupervisedUserAuthenticationTest::~SupervisedUserAuthenticationTest() {}
29 void SupervisedUserAuthenticationTest::SetUp() {}
31 void SupervisedUserAuthenticationTest::TearDown() {}
33 TEST_F(SupervisedUserAuthenticationTest, SignatureGeneration) {
34 std::string password = "password";
37 "204cc733ebe526ea9a84885de904eb7a578d86a4c385d252dce275d9d9675c37";
38 std::string expected_salted_password =
39 "OSL3HZZSfK+mDQTYUh3lXhgAzJNWhYz52ax0Bleny7Q=";
40 std::string signature_key = "p5TR/34XX0R7IMuffH14BiL1vcdSD8EajPzdIg09z9M=";
41 std::string expected_signature =
42 "KOPQmmJcMr9iMkr36N1cX+G9gDdBBu7zutAxNayPMN4=";
45 key.Transform(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, salt);
46 ASSERT_EQ(expected_salted_password, key.GetSecret());
47 std::string signature = SupervisedUserAuthentication::BuildPasswordSignature(
48 key.GetSecret(), revision, signature_key);
49 ASSERT_EQ(expected_signature, signature);
52 } // namespace chromeos