summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-28 13:33:02 +0000
committerjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-28 13:33:02 +0000
commitc0ecd7a17a2c1d6026f4ca8fe4ea24148d4d869c (patch)
treea444cc53090ca4fba4814ffcd564ddd2d246388f
parent05b4f5b221222490bf4e9985f5cfee7d3bfa2ef8 (diff)
downloadchromium_src-c0ecd7a17a2c1d6026f4ca8fe4ea24148d4d869c.zip
chromium_src-c0ecd7a17a2c1d6026f4ca8fe4ea24148d4d869c.tar.gz
chromium_src-c0ecd7a17a2c1d6026f4ca8fe4ea24148d4d869c.tar.bz2
Added DMServer updates to the auto-enrollment protobuf fields.
BUG=chromium-os:23063 TEST=All works as before. unit_tests:AutoEnrollmentClientTest.* Review URL: http://codereview.chromium.org/9044005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115886 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/policy/auto_enrollment_client.cc6
-rw-r--r--chrome/browser/policy/auto_enrollment_client_unittest.cc6
-rw-r--r--chrome/browser/policy/proto/device_management_backend.proto13
-rw-r--r--net/tools/testserver/device_management.py6
4 files changed, 19 insertions, 12 deletions
diff --git a/chrome/browser/policy/auto_enrollment_client.cc b/chrome/browser/policy/auto_enrollment_client.cc
index b3864a4..3b989a7 100644
--- a/chrome/browser/policy/auto_enrollment_client.cc
+++ b/chrome/browser/policy/auto_enrollment_client.cc
@@ -173,9 +173,9 @@ void AutoEnrollmentClient::SendRequest(int power) {
void AutoEnrollmentClient::HandleAutoEnrollmentResponse(
const em::DeviceAutoEnrollmentResponse& response) {
- if (response.has_modulus()) {
+ if (response.has_expected_modulus()) {
// Server is asking us to retry with a different modulus.
- int64 modulus = response.modulus();
+ int64 modulus = response.expected_modulus();
int64 last_modulus_used = 1 << last_power_used_;
int power = NextPowerOf2(modulus);
if ((1 << power) != modulus) {
@@ -204,7 +204,7 @@ void AutoEnrollmentClient::HandleAutoEnrollmentResponse(
}
} else {
// Server should have sent down a list of hashes to try.
- should_auto_enroll_ = IsSerialInProtobuf(response.hashes());
+ should_auto_enroll_ = IsSerialInProtobuf(response.hash());
LOG(INFO) << "Auto enrollment complete, should_auto_enroll = "
<< should_auto_enroll_;
}
diff --git a/chrome/browser/policy/auto_enrollment_client_unittest.cc b/chrome/browser/policy/auto_enrollment_client_unittest.cc
index 742ad84..abaf4eb 100644
--- a/chrome/browser/policy/auto_enrollment_client_unittest.cc
+++ b/chrome/browser/policy/auto_enrollment_client_unittest.cc
@@ -77,17 +77,17 @@ class AutoEnrollmentClientTest : public testing::Test {
void ServerWillReply(int64 modulus, bool with_hashes, bool with_serial_hash) {
em::DeviceAutoEnrollmentResponse response;
if (modulus >= 0)
- response.set_modulus(modulus);
+ response.set_expected_modulus(modulus);
if (with_hashes) {
for (size_t i = 0; i < 10; ++i) {
std::string serial = "serial X";
serial[7] = '0' + i;
std::string hash = crypto::SHA256HashString(serial);
- response.mutable_hashes()->Add()->assign(hash);
+ response.mutable_hash()->Add()->assign(hash);
}
}
if (with_serial_hash) {
- response.mutable_hashes()->Add()->assign(kSerialHash,
+ response.mutable_hash()->Add()->assign(kSerialHash,
crypto::kSHA256Length);
}
EXPECT_CALL(backend_, ProcessAutoEnrollmentRequest(_, _, _))
diff --git a/chrome/browser/policy/proto/device_management_backend.proto b/chrome/browser/policy/proto/device_management_backend.proto
index a331246..6f4f6d4 100644
--- a/chrome/browser/policy/proto/device_management_backend.proto
+++ b/chrome/browser/policy/proto/device_management_backend.proto
@@ -298,7 +298,11 @@ message DeviceAutoEnrollmentRequest {
// Should always be present.
optional int64 remainder = 1;
- // Modulus of the hash used by the client. Should always be present.
+ // Modulus of the hash used by the client. Should always be present. This
+ // is the number of buckets the client thinks the server has. For now,
+ // it is a power of 2, but due to the strict constraint on how many serial
+ // numbers a bucket can contain, it may become non power of 2. If that
+ // happens, client-side needs to change its assumption.
optional int64 modulus = 2;
}
@@ -308,13 +312,16 @@ message DeviceAutoEnrollmentResponse {
// should send a new DeviceAutoEnrollmentRequest with a new |remainder|
// computed using this new |modulus|. If this field is empty, the client's
// request was accepted.
- optional int64 modulus = 1;
+ // DMServer guarantees that if the modulus sent by client in
+ // DeviceAutoEnrollmentRequest matches server's expectation, this field
+ // is unset.
+ optional int64 expected_modulus = 1;
// List of hashes in the client's hash bucket. If the client's hash matches
// any in this list, the client device should do enterprise enrollment.
// If it matches none, enrollment should be optional.
// Each entry has exactly 256 bits (32 bytes).
- repeated bytes hashes = 2;
+ repeated bytes hash = 2;
}
// Request from the DMAgent on the device to the DMServer. This is
diff --git a/net/tools/testserver/device_management.py b/net/tools/testserver/device_management.py
index a12ccbc..7d2fa69 100644
--- a/net/tools/testserver/device_management.py
+++ b/net/tools/testserver/device_management.py
@@ -285,11 +285,11 @@ class RequestHandler(object):
auto_enrollment_response = dm.DeviceAutoEnrollmentResponse()
if msg.modulus == 1:
- auto_enrollment_response.hashes.append(SHA256_0)
+ auto_enrollment_response.hash.append(SHA256_0)
elif msg.modulus == 2:
- auto_enrollment_response.modulus = 4
+ auto_enrollment_response.expected_modulus = 4
elif msg.modulus == 4:
- auto_enrollment_response.modulus = 2
+ auto_enrollment_response.expected_modulus = 2
elif msg.modulus == 8:
return (400, 'Server error')