Removing mnc-brillo-dev specific changes to weaved
Moved recent changes to weaved from Brillo branch to AOSP and used
conditional compilation to compile Brillo-specific code on Brillo only.
This eliminates differences in source files for the branch and future
code merge issues.
Change-Id: I355a1022cb0d31ea1ab7e0c476824ebbad1af43c
diff --git a/buffet/buffet_config.h b/buffet/buffet_config.h
index a286bf8..3db6de8 100644
--- a/buffet/buffet_config.h
+++ b/buffet/buffet_config.h
@@ -12,9 +12,12 @@
#include <base/callback.h>
#include <base/files/file_path.h>
+#include <chromeos/errors/error.h>
#include <chromeos/key_value_store.h>
#include <weave/provider/config_store.h>
+#include "buffet/encryptor.h"
+
namespace buffet {
class StorageInterface;
@@ -39,6 +42,14 @@
std::string test_privet_ssid;
};
+ // An IO abstraction to enable testing without using real files.
+ class FileIO {
+ public:
+ virtual bool ReadFile(const base::FilePath& path, std::string* content) = 0;
+ virtual bool WriteFile(const base::FilePath& path,
+ const std::string& content) = 0;
+ };
+
~BuffetConfig() override = default;
explicit BuffetConfig(const Options& options);
@@ -51,8 +62,28 @@
bool LoadDefaults(const chromeos::KeyValueStore& store,
weave::Settings* settings);
+ // Allows injection of a non-default |encryptor| for testing. The caller
+ // retains ownership of the pointer.
+ void SetEncryptor(Encryptor* encryptor) {
+ encryptor_ = encryptor;
+ }
+
+ // Allows injection of non-default |file_io| for testing. The caller retains
+ // ownership of the pointer.
+ void SetFileIO(FileIO* file_io) {
+ file_io_ = file_io;
+ }
+
private:
+ bool LoadFile(const base::FilePath& file_path,
+ std::string* data,
+ chromeos::ErrorPtr* error);
+
Options options_;
+ std::unique_ptr<Encryptor> default_encryptor_;
+ Encryptor* encryptor_{nullptr};
+ std::unique_ptr<FileIO> default_file_io_;
+ FileIO* file_io_{nullptr};
DISALLOW_COPY_AND_ASSIGN(BuffetConfig);
};