Add test for AuthTokenTable.Clear.
Also fix tests broken by the change from 32 to 64-bit timestamps.
Change-Id: I5a80c6795880fe7231b1d311db7f3e0869913947
diff --git a/keystore/tests/auth_token_table_test.cpp b/keystore/tests/auth_token_table_test.cpp
index 0f74e77..fec7e43 100644
--- a/keystore/tests/auth_token_table_test.cpp
+++ b/keystore/tests/auth_token_table_test.cpp
@@ -72,7 +72,7 @@
}
static hw_auth_token_t* make_token(uint64_t rsid, uint64_t ssid = 0, uint64_t challenge = 0,
- uint32_t timestamp = 0) {
+ uint64_t timestamp = 0) {
hw_auth_token_t* token = new hw_auth_token_t;
token->user_id = rsid;
token->authenticator_id = ssid;
@@ -129,6 +129,25 @@
table.FindAuthorization(make_set(5), 0, &found));
}
+TEST(AuthTokenTableTest, FlushTable) {
+ AuthTokenTable table(3, monotonic_clock);
+
+ table.AddAuthenticationToken(make_token(1));
+ table.AddAuthenticationToken(make_token(2));
+ table.AddAuthenticationToken(make_token(3));
+
+ const hw_auth_token_t* found;
+
+ // All three should be in the table.
+ EXPECT_EQ(3U, table.size());
+ EXPECT_EQ(AuthTokenTable::OK, table.FindAuthorization(make_set(1), 0, &found));
+ EXPECT_EQ(AuthTokenTable::OK, table.FindAuthorization(make_set(2), 0, &found));
+ EXPECT_EQ(AuthTokenTable::OK, table.FindAuthorization(make_set(3), 0, &found));
+
+ table.Clear();
+ EXPECT_EQ(0U, table.size());
+}
+
TEST(AuthTokenTableTest, TableOverflow) {
AuthTokenTable table(3, monotonic_clock);