Chromium Code Reviews| Index: remoting/protocol/key_pair_unittest.cc |
| diff --git a/remoting/host/host_key_pair_unittest.cc b/remoting/protocol/key_pair_unittest.cc |
| similarity index 56% |
| rename from remoting/host/host_key_pair_unittest.cc |
| rename to remoting/protocol/key_pair_unittest.cc |
| index 2aa921c3115dc44a4bb2b9ef9888ed59f0ecd486..5b8aaa563d032208bf0cb3361d02a4b3d8082af0 100644 |
| --- a/remoting/host/host_key_pair_unittest.cc |
| +++ b/remoting/protocol/key_pair_unittest.cc |
| @@ -4,18 +4,13 @@ |
| #include <string> |
| -#include "base/files/scoped_temp_dir.h" |
| -#include "base/memory/ref_counted.h" |
| -#include "base/message_loop.h" |
| -#include "base/message_loop_proxy.h" |
| -#include "base/string_util.h" |
| -#include "remoting/host/host_key_pair.h" |
| -#include "remoting/host/json_host_config.h" |
| -#include "remoting/host/test_key_pair.h" |
| +#include "remoting/protocol/key_pair.h" |
| +#include "remoting/protocol/test_key_pair.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace remoting { |
| +namespace protocol { |
| namespace { |
| const char kTestMessage[] = "Test Message"; |
| @@ -29,42 +24,29 @@ const char kExpectedSignature[] = |
| "BPgvK7rI5Y0ERtVm+yNmH7vCivfyAnDUYA=="; |
| } // namespace |
| -class HostKeyPairTest : public testing::Test { |
| - protected: |
| - virtual void SetUp() { |
| - ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); |
| - base::FilePath config_path = test_dir_.path().AppendASCII("test_config.json"); |
| - config_.reset(new JsonHostConfig(config_path)); |
| - } |
| - |
| - MessageLoop message_loop_; |
| - base::ScopedTempDir test_dir_; |
| - scoped_ptr<JsonHostConfig> config_; |
| +class KeyPairTest : public testing::Test { |
| }; |
| -TEST_F(HostKeyPairTest, SaveLoad) { |
| - // Save a key to a config, then load it back, and verify that we |
| +TEST_F(KeyPairTest, SaveLoad) { |
|
Wez
2013/02/23 03:43:20
nit: LoadSaveLoad ;)
rmsousa
2013/02/26 02:38:52
Done.
|
| + // Load a key to a string, convert to string, load again, and verify that we |
| // generate the same signature with both keys. |
| - HostKeyPair exported_key; |
| + KeyPair exported_key; |
| exported_key.LoadFromString(kTestHostKeyPair); |
| - exported_key.Save(config_.get()); |
| - |
| - message_loop_.RunUntilIdle(); |
| - |
| - HostKeyPair imported_key; |
| - imported_key.Load(*config_); |
| + KeyPair imported_key; |
| + imported_key.LoadFromString(exported_key.GetAsString()); |
| ASSERT_EQ(exported_key.GetSignature(kTestMessage), |
| imported_key.GetSignature(kTestMessage)); |
| } |
| -TEST_F(HostKeyPairTest, Signatures) { |
| +TEST_F(KeyPairTest, Signatures) { |
|
Wez
2013/02/23 03:43:20
nit: We should have tests that differing keys gene
Wez
2013/02/23 03:43:20
Please also add a test for Copy().
rmsousa
2013/02/26 02:38:52
Done.
rmsousa
2013/02/26 02:38:52
Done.
|
| // Sign a message and check that we get expected signature. |
| - HostKeyPair key_pair; |
| + KeyPair key_pair; |
| key_pair.LoadFromString(kTestHostKeyPair); |
| std::string signature_base64 = key_pair.GetSignature(kTestMessage); |
| ASSERT_EQ(signature_base64, std::string(kExpectedSignature)); |
| } |
| +} // namespace protocol |
| } // namespace remoting |