diff options
author | Andres Morales <anmorales@google.com> | 2015-03-19 18:02:55 -0700 |
---|---|---|
committer | Andres Morales <anmorales@google.com> | 2015-03-19 19:20:10 -0700 |
commit | 7d0f0406314df47b7502c3cd72dcefb83ead7132 (patch) | |
tree | 5376f6784d8f222dc596c96b67af5d5e5414c45a /tests | |
parent | edd3e3dc860ff3d99c0320a6ee7d66347b4dd1c3 (diff) | |
download | gatekeeper-7d0f0406314df47b7502c3cd72dcefb83ead7132.tar.gz |
Rename keyguard to gatekeeper
Prevents confusion between this component and the
actual Keyguard that shows when the device is locked.
Change-Id: I47bc02b73947d56841ed126aae4eaf007749038a
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Android.mk | 10 | ||||
-rw-r--r-- | tests/gatekeeper_device_test.cpp (renamed from tests/keyguard_device_test.cpp) | 24 | ||||
-rw-r--r-- | tests/gatekeeper_messages_test.cpp (renamed from tests/keyguard_messages_test.cpp) | 24 | ||||
-rw-r--r-- | tests/gatekeeper_test.cpp (renamed from tests/keyguard_test.cpp) | 118 |
4 files changed, 88 insertions, 88 deletions
diff --git a/tests/Android.mk b/tests/Android.mk index fff72ca..f1238af 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -17,14 +17,14 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE := keyguard-unit-tests +LOCAL_MODULE := gatekeeper-unit-tests LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk LOCAL_CFLAGS += -g -Wall -Werror -std=gnu++11 -Wno-missing-field-initializers -LOCAL_SHARED_LIBRARIES := libkeyguard libcrypto libhardware +LOCAL_SHARED_LIBRARIES := libgatekeeper libcrypto libhardware LOCAL_STATIC_LIBRARIES := libscrypt_static LOCAL_C_INCLUDES := external/scrypt/lib/crypto LOCAL_SRC_FILES := \ - keyguard_messages_test.cpp \ - keyguard_test.cpp \ - keyguard_device_test.cpp + gatekeeper_messages_test.cpp \ + gatekeeper_test.cpp \ + gatekeeper_device_test.cpp include $(BUILD_NATIVE_TEST) diff --git a/tests/keyguard_device_test.cpp b/tests/gatekeeper_device_test.cpp index b3f3b21..c5ad9c3 100644 --- a/tests/keyguard_device_test.cpp +++ b/tests/gatekeeper_device_test.cpp @@ -14,39 +14,39 @@ * limitations under the License. */ #include <gtest/gtest.h> -#include <hardware/keyguard.h> +#include <hardware/gatekeeper.h> using ::testing::Test; -class KeyguardDeviceTest : public virtual Test { +class GateKeeperDeviceTest : public virtual Test { public: - KeyguardDeviceTest() {} - virtual ~KeyguardDeviceTest() {} + GateKeeperDeviceTest() {} + virtual ~GateKeeperDeviceTest() {} virtual void SetUp() { - keyguard_device_initialize(&device); + gatekeeper_device_initialize(&device); } virtual void TearDown() { - keyguard_close(device); + gatekeeper_close(device); } - static void keyguard_device_initialize(keyguard_device_t **dev) { + static void gatekeeper_device_initialize(gatekeeper_device_t **dev) { int ret; const hw_module_t *mod; - ret = hw_get_module_by_class(KEYGUARD_HARDWARE_MODULE_ID, NULL, &mod); + ret = hw_get_module_by_class(GATEKEEPER_HARDWARE_MODULE_ID, NULL, &mod); ASSERT_EQ(0, ret); - ret = keyguard_open(mod, dev); + ret = gatekeeper_open(mod, dev); ASSERT_EQ(0, ret); } - keyguard_device_t *device; + gatekeeper_device_t *device; }; -TEST_F(KeyguardDeviceTest, EnrollAndVerify) { +TEST_F(GateKeeperDeviceTest, EnrollAndVerify) { size_t password_len = 50; uint8_t password_payload[password_len]; uint8_t *password_handle; @@ -66,7 +66,7 @@ TEST_F(KeyguardDeviceTest, EnrollAndVerify) { ASSERT_EQ(0, ret); } -TEST_F(KeyguardDeviceTest, EnrollAndVerifyBadPassword) { +TEST_F(GateKeeperDeviceTest, EnrollAndVerifyBadPassword) { size_t password_len = 50; uint8_t password_payload[password_len]; uint8_t *password_handle; diff --git a/tests/keyguard_messages_test.cpp b/tests/gatekeeper_messages_test.cpp index fd70c07..e58db04 100644 --- a/tests/keyguard_messages_test.cpp +++ b/tests/gatekeeper_messages_test.cpp @@ -19,14 +19,14 @@ #include <stdlib.h> #include <stdio.h> -#include <keyguard/keyguard_messages.h> +#include <gatekeeper/gatekeeper_messages.h> -using ::keyguard::SizedBuffer; +using ::gatekeeper::SizedBuffer; using ::testing::Test; -using ::keyguard::EnrollRequest; -using ::keyguard::EnrollResponse; -using ::keyguard::VerifyRequest; -using ::keyguard::VerifyResponse; +using ::gatekeeper::EnrollRequest; +using ::gatekeeper::EnrollResponse; +using ::gatekeeper::VerifyRequest; +using ::gatekeeper::VerifyResponse; using std::cout; using std::endl; @@ -57,7 +57,7 @@ TEST(RoundTripTest, EnrollRequestNullEnrolledNullHandle) { deserialized_req.Deserialize(serialized_req, serialized_req + req.GetSerializedSize()); delete[] serialized_req; - ASSERT_EQ(keyguard::keyguard_error_t::KG_ERROR_OK, + ASSERT_EQ(gatekeeper::gatekeeper_error_t::ERROR_NONE, deserialized_req.error); deserialized_password = &deserialized_req.provided_password; @@ -84,7 +84,7 @@ TEST(RoundTripTest, EnrollRequestEmptyEnrolledEmptyHandle) { deserialized_req.Deserialize(serialized_req, serialized_req + req.GetSerializedSize()); delete[] serialized_req; - ASSERT_EQ(keyguard::keyguard_error_t::KG_ERROR_OK, + ASSERT_EQ(gatekeeper::gatekeeper_error_t::ERROR_NONE, deserialized_req.error); deserialized_password = &deserialized_req.provided_password; @@ -113,7 +113,7 @@ TEST(RoundTripTest, EnrollRequestNonNullEnrolledOrHandle) { deserialized_req.Deserialize(serialized_req, serialized_req + req.GetSerializedSize()); delete[] serialized_req; - ASSERT_EQ(keyguard::keyguard_error_t::KG_ERROR_OK, + ASSERT_EQ(gatekeeper::gatekeeper_error_t::ERROR_NONE, deserialized_req.error); deserialized_password = &deserialized_req.provided_password; @@ -143,7 +143,7 @@ TEST(RoundTripTest, EnrollResponse) { deserialized_req.Deserialize(serialized_req, serialized_req + req.GetSerializedSize()); delete[] serialized_req; - ASSERT_EQ(keyguard::keyguard_error_t::KG_ERROR_OK, + ASSERT_EQ(gatekeeper::gatekeeper_error_t::ERROR_NONE, deserialized_req.error); deserialized_password = &deserialized_req.enrolled_password_handle; @@ -164,7 +164,7 @@ TEST(RoundTripTest, VerifyRequest) { VerifyRequest deserialized_req; deserialized_req.Deserialize(serialized_req, serialized_req + req.GetSerializedSize()); - ASSERT_EQ(keyguard::keyguard_error_t::KG_ERROR_OK, + ASSERT_EQ(gatekeeper::gatekeeper_error_t::ERROR_NONE, deserialized_req.error); ASSERT_EQ(USER_ID, deserialized_req.user_id); @@ -190,7 +190,7 @@ TEST(RoundTripTest, VerifyResponse) { deserialized_req.Deserialize(serialized_req, serialized_req + req.GetSerializedSize()); delete[] serialized_req; - ASSERT_EQ(keyguard::keyguard_error_t::KG_ERROR_OK, + ASSERT_EQ(gatekeeper::gatekeeper_error_t::ERROR_NONE, deserialized_req.error); ASSERT_EQ(USER_ID, deserialized_req.user_id); diff --git a/tests/keyguard_test.cpp b/tests/gatekeeper_test.cpp index 02a6c34..2c91295 100644 --- a/tests/keyguard_test.cpp +++ b/tests/gatekeeper_test.cpp @@ -18,21 +18,21 @@ #include <UniquePtr.h> #include <iostream> -#include <keyguard/soft_keyguard.h> +#include <gatekeeper/soft_gatekeeper.h> -using ::keyguard::SizedBuffer; +using ::gatekeeper::SizedBuffer; using ::testing::Test; -using ::keyguard::EnrollRequest; -using ::keyguard::EnrollResponse; -using ::keyguard::VerifyRequest; -using ::keyguard::VerifyResponse; -using ::keyguard::SoftKeyguard; -using ::keyguard::AuthToken; -using ::keyguard::secure_id_t; - -class TestKeyguardFileIo : public ::keyguard::KeyguardFileIo { +using ::gatekeeper::EnrollRequest; +using ::gatekeeper::EnrollResponse; +using ::gatekeeper::VerifyRequest; +using ::gatekeeper::VerifyResponse; +using ::gatekeeper::SoftGateKeeper; +using ::gatekeeper::AuthToken; +using ::gatekeeper::secure_id_t; + +class TestGateKeeperFileIo : public ::gatekeeper::GateKeeperFileIo { public: - TestKeyguardFileIo() { + TestGateKeeperFileIo() { bytes_.length = 0; } @@ -56,7 +56,7 @@ public: SizedBuffer bytes_; }; -static void do_enroll(SoftKeyguard &keyguard, EnrollResponse *response) { +static void do_enroll(SoftGateKeeper &gatekeeper, EnrollResponse *response) { SizedBuffer password; password.buffer.reset(new uint8_t[16]); @@ -64,30 +64,30 @@ static void do_enroll(SoftKeyguard &keyguard, EnrollResponse *response) { memset(password.buffer.get(), 0, 16); EnrollRequest request(0, NULL, &password, NULL); - keyguard.Enroll(request, response); + gatekeeper.Enroll(request, response); } -TEST(KeyguardTest, EnrollSuccess) { - SoftKeyguard keyguard(new TestKeyguardFileIo()); +TEST(GateKeeperTest, EnrollSuccess) { + SoftGateKeeper gatekeeper(new TestGateKeeperFileIo()); EnrollResponse response; - do_enroll(keyguard, &response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, response.error); + do_enroll(gatekeeper, &response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, response.error); } -TEST(KeyguardTest, EnrollBogusData) { - SoftKeyguard keyguard(new TestKeyguardFileIo()); +TEST(GateKeeperTest, EnrollBogusData) { + SoftGateKeeper gatekeeper(new TestGateKeeperFileIo()); SizedBuffer password; EnrollResponse response; EnrollRequest request(0, NULL, &password, NULL); - keyguard.Enroll(request, &response); + gatekeeper.Enroll(request, &response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_INVALID, response.error); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_INVALID, response.error); } -TEST(KeyguardTest, VerifySuccess) { - SoftKeyguard keyguard(new TestKeyguardFileIo()); +TEST(GateKeeperTest, VerifySuccess) { + SoftGateKeeper gatekeeper(new TestGateKeeperFileIo()); SizedBuffer provided_password; EnrollResponse enroll_response; @@ -95,15 +95,15 @@ TEST(KeyguardTest, VerifySuccess) { provided_password.length = 16; memset(provided_password.buffer.get(), 0, 16); - do_enroll(keyguard, &enroll_response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, enroll_response.error); + do_enroll(gatekeeper, &enroll_response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, enroll_response.error); VerifyRequest request(0, &enroll_response.enrolled_password_handle, &provided_password); VerifyResponse response; - keyguard.Verify(request, &response); + gatekeeper.Verify(request, &response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, response.error); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, response.error); AuthToken *auth_token = reinterpret_cast<AuthToken *>(response.auth_token.buffer.get()); @@ -114,24 +114,24 @@ TEST(KeyguardTest, VerifySuccess) { ASSERT_NE((uint64_t) 0, auth_token->auxiliary_secure_user_id); } -TEST(KeyguardTest, VerifyBadPwFile) { - TestKeyguardFileIo *fw = new TestKeyguardFileIo(); - SoftKeyguard keyguard(fw); +TEST(GateKeeperTest, VerifyBadPwFile) { + TestGateKeeperFileIo *fw = new TestGateKeeperFileIo(); + SoftGateKeeper gatekeeper(fw); SizedBuffer provided_password; EnrollResponse enroll_response; provided_password.buffer.reset(new uint8_t[16]); provided_password.length = 16; memset(provided_password.buffer.get(), 0, 16); - do_enroll(keyguard, &enroll_response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, enroll_response.error); + do_enroll(gatekeeper, &enroll_response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, enroll_response.error); VerifyRequest request(0, &enroll_response.enrolled_password_handle, &provided_password); VerifyResponse response; fw->bytes_.buffer.reset(); - keyguard.Verify(request, &response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, response.error); + gatekeeper.Verify(request, &response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, response.error); AuthToken *auth_token = reinterpret_cast<AuthToken *>(response.auth_token.buffer.get()); @@ -142,8 +142,8 @@ TEST(KeyguardTest, VerifyBadPwFile) { ASSERT_EQ((uint64_t) 0, auth_token->auxiliary_secure_user_id); } -TEST(KeyguardTest, TrustedReEnroll) { - SoftKeyguard keyguard(new TestKeyguardFileIo()); +TEST(GateKeeperTest, TrustedReEnroll) { + SoftGateKeeper gatekeeper(new TestGateKeeperFileIo()); SizedBuffer provided_password; EnrollResponse enroll_response; SizedBuffer password_handle; @@ -152,8 +152,8 @@ TEST(KeyguardTest, TrustedReEnroll) { provided_password.buffer.reset(new uint8_t[16]); provided_password.length = 16; memset(provided_password.buffer.get(), 0, 16); - do_enroll(keyguard, &enroll_response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, enroll_response.error); + do_enroll(gatekeeper, &enroll_response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, enroll_response.error); // keep a copy of the handle password_handle.buffer.reset(new uint8_t[enroll_response.enrolled_password_handle.length]); @@ -165,8 +165,8 @@ TEST(KeyguardTest, TrustedReEnroll) { VerifyRequest request(0, &enroll_response.enrolled_password_handle, &provided_password); VerifyResponse response; - keyguard.Verify(request, &response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, response.error); + gatekeeper.Verify(request, &response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, response.error); AuthToken *auth_token = reinterpret_cast<AuthToken *>(response.auth_token.buffer.get()); @@ -181,8 +181,8 @@ TEST(KeyguardTest, TrustedReEnroll) { memset(password.buffer.get(), 1, 16); password.length = 16; EnrollRequest enroll_request(0, &password_handle, &password, &provided_password); - keyguard.Enroll(enroll_request, &enroll_response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, enroll_response.error); + gatekeeper.Enroll(enroll_request, &enroll_response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, enroll_response.error); // verify new password password.buffer.reset(new uint8_t[16]); @@ -190,15 +190,15 @@ TEST(KeyguardTest, TrustedReEnroll) { password.length = 16; VerifyRequest new_request(0, &enroll_response.enrolled_password_handle, &password); - keyguard.Verify(new_request, &response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, response.error); + gatekeeper.Verify(new_request, &response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, response.error); ASSERT_EQ(secure_id, reinterpret_cast<AuthToken *>(response.auth_token.buffer.get())->root_secure_user_id); } -TEST(KeyguardTest, UntrustedReEnroll) { - SoftKeyguard keyguard(new TestKeyguardFileIo()); +TEST(GateKeeperTest, UntrustedReEnroll) { + SoftGateKeeper gatekeeper(new TestGateKeeperFileIo()); SizedBuffer provided_password; EnrollResponse enroll_response; @@ -206,15 +206,15 @@ TEST(KeyguardTest, UntrustedReEnroll) { provided_password.buffer.reset(new uint8_t[16]); provided_password.length = 16; memset(provided_password.buffer.get(), 0, 16); - do_enroll(keyguard, &enroll_response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, enroll_response.error); + do_enroll(gatekeeper, &enroll_response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, enroll_response.error); // verify first password VerifyRequest request(0, &enroll_response.enrolled_password_handle, &provided_password); VerifyResponse response; - keyguard.Verify(request, &response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, response.error); + gatekeeper.Verify(request, &response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, response.error); AuthToken *auth_token = reinterpret_cast<AuthToken *>(response.auth_token.buffer.get()); @@ -226,8 +226,8 @@ TEST(KeyguardTest, UntrustedReEnroll) { memset(password.buffer.get(), 1, 16); password.length = 16; EnrollRequest enroll_request(0, NULL, &password, NULL); - keyguard.Enroll(enroll_request, &enroll_response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, enroll_response.error); + gatekeeper.Enroll(enroll_request, &enroll_response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, enroll_response.error); // verify new password password.buffer.reset(new uint8_t[16]); @@ -235,22 +235,22 @@ TEST(KeyguardTest, UntrustedReEnroll) { password.length = 16; VerifyRequest new_request(0, &enroll_response.enrolled_password_handle, &password); - keyguard.Verify(new_request, &response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_OK, response.error); + gatekeeper.Verify(new_request, &response); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_NONE, response.error); ASSERT_NE(secure_id, reinterpret_cast<AuthToken *>(response.auth_token.buffer.get())->root_secure_user_id); } -TEST(KeyguardTest, VerifyBogusData) { - SoftKeyguard keyguard(new TestKeyguardFileIo()); +TEST(GateKeeperTest, VerifyBogusData) { + SoftGateKeeper gatekeeper(new TestGateKeeperFileIo()); SizedBuffer provided_password; SizedBuffer password_handle; VerifyResponse response; VerifyRequest request(0, &provided_password, &password_handle); - keyguard.Verify(request, &response); + gatekeeper.Verify(request, &response); - ASSERT_EQ(::keyguard::keyguard_error_t::KG_ERROR_INVALID, response.error); + ASSERT_EQ(::gatekeeper::gatekeeper_error_t::ERROR_INVALID, response.error); } |