AU: Remove instances of Omaha ID -- machine ID and user ID.

Also add a unit test to make sure we are not sending machineid or userid
attributes.

BUG=1439
TEST=unit tests, gmerged on device, checked for update, looked at logs

Review URL: http://codereview.chromium.org/2808082
diff --git a/omaha_request_action.h b/omaha_request_action.h
index c5f4d19..6f30a32 100644
--- a/omaha_request_action.h
+++ b/omaha_request_action.h
@@ -145,7 +145,7 @@
   // be sent as pings to Omaha.
   void InitPingDays();
 
-  // Based on the perstitent preference store values, calculates the
+  // Based on the persistent preference store values, calculates the
   // number of days since the last ping sent for |key|.
   int CalculatePingDays(const std::string& key);
 
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 5ac0811..f4dcd1e 100755
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -35,8 +35,6 @@
 
 namespace {
 const OmahaRequestParams kDefaultTestParams(
-    "machine_id",
-    "user_id",
     OmahaRequestParams::kOsPlatform,
     OmahaRequestParams::kOsVersion,
     "service_pack",
@@ -406,9 +404,7 @@
   vector<char> post_data;
 
   // Make sure XML Encode is being called on the params
-  OmahaRequestParams params("testthemachine<id",
-                            "testtheuser_id&lt;",
-                            OmahaRequestParams::kOsPlatform,
+  OmahaRequestParams params(OmahaRequestParams::kOsPlatform,
                             OmahaRequestParams::kOsVersion,
                             "testtheservice_pack>",
                             "x86 generic<id",
@@ -576,9 +572,7 @@
     bool delta_okay = i == 1;
     const char* delta_okay_str = delta_okay ? "true" : "false";
     vector<char> post_data;
-    OmahaRequestParams params("machine_id",
-                              "user_id",
-                              OmahaRequestParams::kOsPlatform,
+    OmahaRequestParams params(OmahaRequestParams::kOsPlatform,
                               OmahaRequestParams::kOsVersion,
                               "service_pack",
                               "x86-generic",
@@ -738,7 +732,7 @@
 
 TEST(OmahaRequestActionTest, LastPingDayUpdateTest) {
   // This test checks that the action updates the last ping day to now
-  // minus 200 seconds with a slack for 5 seconds. Therefore, the test
+  // minus 200 seconds with a slack of 5 seconds. Therefore, the test
   // may fail if it runs for longer than 5 seconds. It shouldn't run
   // that long though.
   int64_t midnight =
@@ -799,4 +793,18 @@
                       NULL));
 }
 
+TEST(OmahaRequestActionTest, NoUniqueIDTest) {
+  vector<char> post_data;
+  ASSERT_FALSE(TestUpdateCheck(NULL,  // prefs
+                               kDefaultTestParams,
+                               "invalid xml>",
+                               kActionCodeError,
+                               NULL,  // response
+                               &post_data));
+  // convert post_data to string
+  string post_str(&post_data[0], post_data.size());
+  EXPECT_EQ(post_str.find("machineid="), string::npos);
+  EXPECT_EQ(post_str.find("userid="), string::npos);
+}
+
 }  // namespace chromeos_update_engine
diff --git a/omaha_request_params.cc b/omaha_request_params.cc
index 33281ee..0789fbb 100644
--- a/omaha_request_params.cc
+++ b/omaha_request_params.cc
@@ -18,13 +18,6 @@
 using std::map;
 using std::string;
 
-namespace {
-const string OmahaIdPath() {
-  return string(chromeos_update_engine::utils::kStatefulPartition) +
-      "/etc/omaha_id";
-}
-}  // namespace {}
-
 namespace chromeos_update_engine {
 
 const char* const OmahaRequestParams::kAppId(
@@ -36,8 +29,6 @@
 
 bool OmahaRequestDeviceParams::Init(const std::string& in_app_version,
                                     const std::string& in_update_url) {
-  TEST_AND_RETURN_FALSE(GetMachineId(&machine_id));
-  user_id = machine_id;
   os_platform = OmahaRequestParams::kOsPlatform;
   os_version = OmahaRequestParams::kOsVersion;
   app_version = in_app_version.empty() ?
@@ -61,48 +52,6 @@
   return true;
 }
 
-namespace {
-const size_t kGuidDataByteLength = 128 / 8;
-const string::size_type kGuidStringLength = 38;
-// Formats 16 bytes (128 bits) of data as a GUID:
-// "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" where X is a hex digit
-string GuidFromData(const unsigned char data[kGuidDataByteLength]) {
-  return StringPrintf(
-      "{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
-      data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7],
-      data[8], data[9], data[10], data[11], data[12], data[13], data[14],
-      data[15]);
-}
-}
-
-// Returns true on success.
-bool OmahaRequestDeviceParams::GetMachineId(std::string* out_id) const {
-  // Checks if we have an existing Machine ID.
-  const string omaha_id_path = root_ + OmahaIdPath();
-
-  if (utils::ReadFileToString(omaha_id_path, out_id) &&
-      out_id->size() == kGuidStringLength) {
-    return true;
-  }
-
-  // Creates a new ID.
-  int rand_fd = open("/dev/urandom", O_RDONLY, 0);
-  TEST_AND_RETURN_FALSE_ERRNO(rand_fd >= 0);
-  ScopedFdCloser rand_fd_closer(&rand_fd);
-  unsigned char buf[kGuidDataByteLength];
-  size_t bytes_read = 0;
-  while (bytes_read < sizeof(buf)) {
-    ssize_t rc = read(rand_fd, buf + bytes_read, sizeof(buf) - bytes_read);
-    TEST_AND_RETURN_FALSE_ERRNO(rc > 0);
-    bytes_read += rc;
-  }
-  string guid = GuidFromData(buf);
-  TEST_AND_RETURN_FALSE(
-      utils::WriteFile(omaha_id_path.c_str(), guid.data(), guid.size()));
-  *out_id = guid;
-  return true;
-}
-
 string OmahaRequestDeviceParams::GetLsbValue(
     const string& key, const string& default_value) const {
   string files[] = {string(utils::kStatefulPartition) + "/etc/lsb-release",
diff --git a/omaha_request_params.h b/omaha_request_params.h
index 16def25..9c37258 100644
--- a/omaha_request_params.h
+++ b/omaha_request_params.h
@@ -19,9 +19,7 @@
 struct OmahaRequestParams {
   OmahaRequestParams()
       : os_platform(kOsPlatform), os_version(kOsVersion), app_id(kAppId) {}
-  OmahaRequestParams(const std::string& in_machine_id,
-                     const std::string& in_user_id,
-                     const std::string& in_os_platform,
+  OmahaRequestParams(const std::string& in_os_platform,
                      const std::string& in_os_version,
                      const std::string& in_os_sp,
                      const std::string& in_os_board,
@@ -31,9 +29,7 @@
                      const std::string& in_app_track,
                      const bool in_delta_okay,
                      const std::string& in_update_url)
-      : machine_id(in_machine_id),
-        user_id(in_user_id),
-        os_platform(in_os_platform),
+      : os_platform(in_os_platform),
         os_version(in_os_version),
         os_sp(in_os_sp),
         os_board(in_os_board),
@@ -44,8 +40,6 @@
         delta_okay(in_delta_okay),
         update_url(in_update_url) {}
 
-  std::string machine_id;
-  std::string user_id;
   std::string os_platform;
   std::string os_version;
   std::string os_sp;
@@ -79,9 +73,6 @@
   void set_root(const std::string& root) { root_ = root; }
 
  private:
-  // Gets a machine-local ID (for now, first MAC address we find).
-  bool GetMachineId(std::string* out_id) const;
-
   // Fetches the value for a given key from
   // /mnt/stateful_partition/etc/lsb-release if possible. Failing that,
   // it looks for the key in /etc/lsb-release.
diff --git a/omaha_request_params_unittest.cc b/omaha_request_params_unittest.cc
index 07615a2..19898f4 100644
--- a/omaha_request_params_unittest.cc
+++ b/omaha_request_params_unittest.cc
@@ -49,27 +49,6 @@
 }
 
 namespace {
-bool IsHexDigit(char c) {
-  return ((c >= '0') && (c <= '9')) ||
-      ((c >= 'a') && (c <= 'f')) ||
-      ((c >= 'A') && (c <= 'F'));
-}
-
-// Returns true iff str is formatted as a GUID. Example GUID:
-// "{2251FFAD-DBAB-4E53-8B3A-18F98BB4EB80}"
-bool IsValidGuid(const string& str) {
-  TEST_AND_RETURN_FALSE(str.size() == 38);
-  TEST_AND_RETURN_FALSE((*str.begin() == '{') && (*str.rbegin() == '}'));
-  for (string::size_type i = 1; i < (str.size() - 1); ++i) {
-    if ((i == 9) || (i == 14) || (i == 19) || (i == 24)) {
-      TEST_AND_RETURN_FALSE(str[i] == '-');
-    } else {
-      TEST_AND_RETURN_FALSE(IsHexDigit(str[i]));
-    }
-  }
-  return true;
-}
-
 string GetMachineType() {
   FILE* fp = popen("uname -m", "r");
   if (!fp)
@@ -100,9 +79,6 @@
       "CHROMEOS_AUSERVER=http://www.google.com"));
   OmahaRequestParams out;
   EXPECT_TRUE(DoTest(&out, "", ""));
-  EXPECT_TRUE(IsValidGuid(out.machine_id)) << "id: " << out.machine_id;
-  // for now we're just using the machine id here
-  EXPECT_TRUE(IsValidGuid(out.user_id)) << "id: " << out.user_id;
   EXPECT_EQ("Chrome OS", out.os_platform);
   EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp);
   EXPECT_EQ("arm-generic", out.os_board);
@@ -122,9 +98,6 @@
       "CHROMEOS_RELEASE_TRXCK=footrack"));
   OmahaRequestParams out;
   EXPECT_TRUE(DoTest(&out, "", ""));
-  EXPECT_TRUE(IsValidGuid(out.machine_id));
-  // for now we're just using the machine id here
-  EXPECT_TRUE(IsValidGuid(out.user_id));
   EXPECT_EQ("Chrome OS", out.os_platform);
   EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp);
   EXPECT_EQ("{87efface-864d-49a5-9bb3-4b050a7c227a}", out.app_id);
@@ -141,9 +114,6 @@
       "CHROMEOS_RELEASE_TRXCK=footrack"));
   OmahaRequestParams out;
   EXPECT_TRUE(DoTest(&out, "", ""));
-  EXPECT_TRUE(IsValidGuid(out.machine_id)) << out.machine_id;
-  // for now we're just using the machine id here
-  EXPECT_TRUE(IsValidGuid(out.user_id));
   EXPECT_EQ("Chrome OS", out.os_platform);
   EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp);
   EXPECT_EQ("{87efface-864d-49a5-9bb3-4b050a7c227a}", out.app_id);
@@ -152,25 +122,6 @@
   EXPECT_EQ("", out.app_track);
 }
 
-TEST_F(OmahaRequestDeviceParamsTest, MachineIdPersistsTest) {
-  ASSERT_TRUE(WriteFileString(
-      kTestDir + "/etc/lsb-release",
-      "CHROMEOS_RELEASE_FOO=CHROMEOS_RELEASE_VERSION=1.2.3.4\n"
-      "CHROMEOS_RELEASE_VERSION=0.2.2.3\n"
-      "CHROMEOS_RELEASE_TRXCK=footrack"));
-  OmahaRequestParams out1;
-  EXPECT_TRUE(DoTest(&out1, "", ""));
-  string machine_id;
-  EXPECT_TRUE(utils::ReadFileToString(
-      kTestDir +
-      utils::kStatefulPartition + "/etc/omaha_id",
-      &machine_id));
-  EXPECT_EQ(machine_id, out1.machine_id);
-  OmahaRequestParams out2;
-  EXPECT_TRUE(DoTest(&out2, "", ""));
-  EXPECT_EQ(machine_id, out2.machine_id);
-}
-
 TEST_F(OmahaRequestDeviceParamsTest, MissingVersionTest) {
   ASSERT_TRUE(WriteFileString(
       kTestDir + "/etc/lsb-release",
@@ -179,9 +130,6 @@
       "CHROMEOS_RELEASE_TRACK=footrack"));
   OmahaRequestParams out;
   EXPECT_TRUE(DoTest(&out, "", ""));
-  EXPECT_TRUE(IsValidGuid(out.machine_id)) << "id: " << out.machine_id;
-  // for now we're just using the machine id here
-  EXPECT_TRUE(IsValidGuid(out.user_id)) << "id: " << out.user_id;
   EXPECT_EQ("Chrome OS", out.os_platform);
   EXPECT_EQ(string("_") + GetMachineType(), out.os_sp);
   EXPECT_EQ("arm-generic", out.os_board);
@@ -200,9 +148,6 @@
       "CHROMEOS_RELEASE_TRACK=footrack"));
   OmahaRequestParams out;
   EXPECT_TRUE(DoTest(&out, "ForcedVersion", ""));
-  EXPECT_TRUE(IsValidGuid(out.machine_id)) << "id: " << out.machine_id;
-  // for now we're just using the machine id here
-  EXPECT_TRUE(IsValidGuid(out.user_id)) << "id: " << out.user_id;
   EXPECT_EQ("Chrome OS", out.os_platform);
   EXPECT_EQ(string("ForcedVersion_") + GetMachineType(), out.os_sp);
   EXPECT_EQ("arm-generic", out.os_board);
@@ -222,9 +167,6 @@
       "CHROMEOS_RELEASE_TRACK=footrack"));
   OmahaRequestParams out;
   EXPECT_TRUE(DoTest(&out, "", "http://forced.google.com"));
-  EXPECT_TRUE(IsValidGuid(out.machine_id)) << "id: " << out.machine_id;
-  // for now we're just using the machine id here
-  EXPECT_TRUE(IsValidGuid(out.user_id)) << "id: " << out.user_id;
   EXPECT_EQ("Chrome OS", out.os_platform);
   EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp);
   EXPECT_EQ("arm-generic", out.os_board);
@@ -245,9 +187,6 @@
       "CHROMEOS_RELEASE_TRACK=footrack"));
   OmahaRequestParams out;
   EXPECT_TRUE(DoTest(&out, "", ""));
-  EXPECT_TRUE(IsValidGuid(out.machine_id)) << "id: " << out.machine_id;
-  // for now we're just using the machine id here
-  EXPECT_TRUE(IsValidGuid(out.user_id)) << "id: " << out.user_id;
   EXPECT_EQ("Chrome OS", out.os_platform);
   EXPECT_EQ(string("0.2.2.3_") + GetMachineType(), out.os_sp);
   EXPECT_EQ("arm-generic", out.os_board);