pin_hash_unittest.cc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (c) 2012 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 <set>
  5. #include <string>
  6. #include "remoting/host/pin_hash.h"
  7. #include "testing/gtest/include/gtest/gtest.h"
  8. namespace remoting {
  9. class PinHashTest : public testing::Test {
  10. };
  11. TEST_F(PinHashTest, KnownHashValue) {
  12. std::string hash = MakeHostPinHash("Host ID", "1234");
  13. ASSERT_EQ("hmac:bk6RVRFLpLO89mr4QPHSg8CemUUtI90r2F0VfvTmWLI=", hash);
  14. }
  15. TEST_F(PinHashTest, VerifyHostPinHash) {
  16. std::string host_id1("Host ID 1");
  17. std::string host_id2("Host ID 2");
  18. std::string pin1("1234");
  19. std::string pin2("4321");
  20. ASSERT_TRUE(VerifyHostPinHash(MakeHostPinHash(host_id1, pin1),
  21. host_id1,
  22. pin1));
  23. ASSERT_FALSE(VerifyHostPinHash(MakeHostPinHash(host_id1, pin1),
  24. host_id2,
  25. pin1));
  26. ASSERT_FALSE(VerifyHostPinHash(MakeHostPinHash(host_id1, pin1),
  27. host_id1,
  28. pin2));
  29. }
  30. } // namespace remoting