Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: components/webdata/common/web_database_migration_unittest.cc

Issue 2109643003: Add billing address to masked server credit cards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add version_66.sql to the build file. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/webdata/common/web_database.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // > .output version_nn.sql 123 // > .output version_nn.sql
124 // > .dump 124 // > .dump
125 void LoadDatabase(const base::FilePath::StringType& file); 125 void LoadDatabase(const base::FilePath::StringType& file);
126 126
127 private: 127 private:
128 base::ScopedTempDir temp_dir_; 128 base::ScopedTempDir temp_dir_;
129 129
130 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest); 130 DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
131 }; 131 };
132 132
133 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 66; 133 const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 67;
134 134
135 void WebDatabaseMigrationTest::LoadDatabase( 135 void WebDatabaseMigrationTest::LoadDatabase(
136 const base::FilePath::StringType& file) { 136 const base::FilePath::StringType& file) {
137 std::string contents; 137 std::string contents;
138 ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents)); 138 ASSERT_TRUE(GetWebDatabaseData(base::FilePath(file), &contents));
139 139
140 sql::Connection connection; 140 sql::Connection connection;
141 ASSERT_TRUE(connection.Open(GetDatabasePath())); 141 ASSERT_TRUE(connection.Open(GetDatabasePath()));
142 ASSERT_TRUE(connection.Execute(contents.data())); 142 ASSERT_TRUE(connection.Execute(contents.data()));
143 } 143 }
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 EXPECT_TRUE(connection.DoesColumnExist("credit_cards", 1019 EXPECT_TRUE(connection.DoesColumnExist("credit_cards",
1020 "billing_address_id")); 1020 "billing_address_id"));
1021 1021
1022 sql::Statement read_credit_cards(connection.GetUniqueStatement( 1022 sql::Statement read_credit_cards(connection.GetUniqueStatement(
1023 "SELECT name_on_card, billing_address_id FROM credit_cards")); 1023 "SELECT name_on_card, billing_address_id FROM credit_cards"));
1024 ASSERT_TRUE(read_credit_cards.Step()); 1024 ASSERT_TRUE(read_credit_cards.Step());
1025 EXPECT_EQ("Alice", read_credit_cards.ColumnString(0)); 1025 EXPECT_EQ("Alice", read_credit_cards.ColumnString(0));
1026 EXPECT_TRUE(read_credit_cards.ColumnString(1).empty()); 1026 EXPECT_TRUE(read_credit_cards.ColumnString(1).empty());
1027 } 1027 }
1028 } 1028 }
1029
1030 // Tests addition of masked server credit card billing address.
1031 TEST_F(WebDatabaseMigrationTest, MigrateVersion66ToCurrent) {
1032 ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_66.sql")));
1033
1034 // Verify pre-conditions.
1035 {
1036 sql::Connection connection;
1037 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1038 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
1039
1040 sql::MetaTable meta_table;
1041 ASSERT_TRUE(meta_table.Init(&connection, 66, 66));
1042
1043 EXPECT_FALSE(connection.DoesColumnExist("masked_credit_cards",
1044 "billing_address_id"));
1045
1046 EXPECT_TRUE(connection.Execute(
1047 "INSERT INTO masked_credit_cards(id, name_on_card) "
1048 "VALUES ('id', 'Alice')"));
1049 }
1050
1051 DoMigration();
1052
1053 // Verify post-conditions.
1054 {
1055 sql::Connection connection;
1056 ASSERT_TRUE(connection.Open(GetDatabasePath()));
1057 ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
1058
1059 // Check version.
1060 EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
1061
1062 EXPECT_TRUE(connection.DoesColumnExist("masked_credit_cards",
1063 "billing_address_id"));
1064
1065 sql::Statement read_masked(connection.GetUniqueStatement(
1066 "SELECT name_on_card, billing_address_id FROM masked_credit_cards"));
1067 ASSERT_TRUE(read_masked.Step());
1068 EXPECT_EQ("Alice", read_masked.ColumnString(0));
1069 EXPECT_TRUE(read_masked.ColumnString(1).empty());
1070 }
1071 }
OLDNEW
« no previous file with comments | « components/webdata/common/web_database.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698