AU: Add a signing test with a private key that doesn't match the public one.
Also add a test that payload verification succeeds if the public key file is not
present.
BUG=chromium-os:10936
TEST=unit tests
Change-Id: I429b94f90dde5ee7503c364d07761b203ba5111a
Review URL: http://codereview.chromium.org/6346003
diff --git a/utils.h b/utils.h
index 86ccfb7..74711a8 100644
--- a/utils.h
+++ b/utils.h
@@ -294,15 +294,20 @@
// Utility class to delete a file when it goes out of scope.
class ScopedPathUnlinker {
public:
- explicit ScopedPathUnlinker(const std::string& path) : path_(path) {}
+ explicit ScopedPathUnlinker(const std::string& path)
+ : path_(path),
+ should_remove_(true) {}
~ScopedPathUnlinker() {
- if (unlink(path_.c_str()) < 0) {
+ if (should_remove_ && unlink(path_.c_str()) < 0) {
std::string err_message = strerror(errno);
LOG(ERROR) << "Unable to unlink path " << path_ << ": " << err_message;
}
}
+ void set_should_remove(bool should_remove) { should_remove_ = should_remove; }
+
private:
const std::string path_;
+ bool should_remove_;
DISALLOW_COPY_AND_ASSIGN(ScopedPathUnlinker);
};