Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / managed / supervised_user_authentication_unittest.cc
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/managed/supervised_user_authentication.h"
5
6 #include "base/values.h"
7 #include "chrome/browser/chromeos/login/supervised_user_manager.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace chromeos {
11
12 class SupervisedUserAuthenticationTest : public testing::Test {
13  protected:
14   SupervisedUserAuthenticationTest();
15   virtual ~SupervisedUserAuthenticationTest();
16
17   // testing::Test:
18   virtual void SetUp() OVERRIDE;
19   virtual void TearDown() OVERRIDE;
20
21   DISALLOW_COPY_AND_ASSIGN(SupervisedUserAuthenticationTest);
22 };
23
24 SupervisedUserAuthenticationTest::SupervisedUserAuthenticationTest() {}
25
26 SupervisedUserAuthenticationTest::~SupervisedUserAuthenticationTest() {}
27
28 void SupervisedUserAuthenticationTest::SetUp() {}
29
30 void SupervisedUserAuthenticationTest::TearDown() {}
31
32 TEST_F(SupervisedUserAuthenticationTest, SignatureGeneration) {
33   std::string password = "password";
34   int revision = 1;
35   std::string salt =
36       "204cc733ebe526ea9a84885de904eb7a578d86a4c385d252dce275d9d9675c37";
37   std::string expected_salted_password =
38       "OSL3HZZSfK+mDQTYUh3lXhgAzJNWhYz52ax0Bleny7Q=";
39   std::string signature_key = "p5TR/34XX0R7IMuffH14BiL1vcdSD8EajPzdIg09z9M=";
40   std::string expected_signature =
41       "KOPQmmJcMr9iMkr36N1cX+G9gDdBBu7zutAxNayPMN4=";
42
43   std::string salted_password =
44       SupervisedUserAuthentication::BuildPasswordForHashWithSaltSchema(
45           salt, password);
46   ASSERT_EQ(expected_salted_password, salted_password);
47   std::string signature = SupervisedUserAuthentication::BuildPasswordSignature(
48       salted_password, revision, signature_key);
49   ASSERT_EQ(expected_signature, signature);
50 }
51
52 }  //  namespace chromeos