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

Side by Side Diff: components/policy/core/common/cloud/cloud_policy_client_unittest.cc

Issue 116273002: Added support for signed policy blobs on desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for ios. Created 6 years, 10 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 | Annotate | Revision Log
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 "components/policy/core/common/cloud/cloud_policy_client.h" 5 #include "components/policy/core/common/cloud/cloud_policy_client.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 registration_request_.mutable_register_request(); 76 registration_request_.mutable_register_request();
77 register_request->set_type(em::DeviceRegisterRequest::USER); 77 register_request->set_type(em::DeviceRegisterRequest::USER);
78 register_request->set_machine_id(kMachineID); 78 register_request->set_machine_id(kMachineID);
79 register_request->set_machine_model(kMachineModel); 79 register_request->set_machine_model(kMachineModel);
80 registration_response_.mutable_register_response()-> 80 registration_response_.mutable_register_response()->
81 set_device_management_token(kDMToken); 81 set_device_management_token(kDMToken);
82 82
83 em::PolicyFetchRequest* policy_fetch_request = 83 em::PolicyFetchRequest* policy_fetch_request =
84 policy_request_.mutable_policy_request()->add_request(); 84 policy_request_.mutable_policy_request()->add_request();
85 policy_fetch_request->set_policy_type(dm_protocol::kChromeUserPolicyType); 85 policy_fetch_request->set_policy_type(dm_protocol::kChromeUserPolicyType);
86 #if defined(OS_CHROMEOS)
87 policy_fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); 86 policy_fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA);
88 #else 87 policy_fetch_request->set_verification_key_hash(kPolicyVerificationKeyHash);
89 policy_fetch_request->set_signature_type(em::PolicyFetchRequest::NONE);
90 #endif
91 policy_response_.mutable_policy_response()->add_response()->set_policy_data( 88 policy_response_.mutable_policy_response()->add_response()->set_policy_data(
92 CreatePolicyData("fake-policy-data")); 89 CreatePolicyData("fake-policy-data"));
93 90
94 unregistration_request_.mutable_unregister_request(); 91 unregistration_request_.mutable_unregister_request();
95 unregistration_response_.mutable_unregister_response(); 92 unregistration_response_.mutable_unregister_response();
96 upload_certificate_request_.mutable_cert_upload_request()-> 93 upload_certificate_request_.mutable_cert_upload_request()->
97 set_device_certificate(kDeviceCertificate); 94 set_device_certificate(kDeviceCertificate);
98 upload_certificate_response_.mutable_cert_upload_response(); 95 upload_certificate_response_.mutable_cert_upload_response();
99 } 96 }
100 97
(...skipping 14 matching lines...) Expand all
115 client_->SetupRegistration(kDMToken, client_id_); 112 client_->SetupRegistration(kDMToken, client_id_);
116 } 113 }
117 114
118 void CreateClient(UserAffiliation user_affiliation) { 115 void CreateClient(UserAffiliation user_affiliation) {
119 if (client_.get()) 116 if (client_.get())
120 client_->RemoveObserver(&observer_); 117 client_->RemoveObserver(&observer_);
121 118
122 request_context_ = new net::TestURLRequestContextGetter( 119 request_context_ = new net::TestURLRequestContextGetter(
123 loop_.message_loop_proxy()); 120 loop_.message_loop_proxy());
124 client_.reset(new CloudPolicyClient(kMachineID, kMachineModel, 121 client_.reset(new CloudPolicyClient(kMachineID, kMachineModel,
122 kPolicyVerificationKeyHash,
125 user_affiliation, &status_provider_, 123 user_affiliation, &status_provider_,
126 &service_, 124 &service_,
127 request_context_)); 125 request_context_));
128 client_->AddNamespaceToFetch(policy_ns_key_); 126 client_->AddNamespaceToFetch(policy_ns_key_);
129 client_->AddObserver(&observer_); 127 client_->AddObserver(&observer_);
130 } 128 }
131 129
132 void ExpectRegistration(const std::string& oauth_token) { 130 void ExpectRegistration(const std::string& oauth_token) {
133 EXPECT_CALL(service_, 131 EXPECT_CALL(service_,
134 CreateJob(DeviceManagementRequestJob::TYPE_REGISTRATION, 132 CreateJob(DeviceManagementRequestJob::TYPE_REGISTRATION,
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 EXPECT_CALL(service_, StartJob(_, _, _, _, _, _, _)); 578 EXPECT_CALL(service_, StartJob(_, _, _, _, _, _, _));
581 EXPECT_CALL(observer_, OnClientError(_)); 579 EXPECT_CALL(observer_, OnClientError(_));
582 CloudPolicyClient::StatusCallback callback = base::Bind( 580 CloudPolicyClient::StatusCallback callback = base::Bind(
583 &MockUploadCertificateObserver::OnUploadComplete, 581 &MockUploadCertificateObserver::OnUploadComplete,
584 base::Unretained(&upload_certificate_observer_)); 582 base::Unretained(&upload_certificate_observer_));
585 client_->UploadCertificate(kDeviceCertificate, callback); 583 client_->UploadCertificate(kDeviceCertificate, callback);
586 EXPECT_EQ(DM_STATUS_REQUEST_FAILED, client_->status()); 584 EXPECT_EQ(DM_STATUS_REQUEST_FAILED, client_->status());
587 } 585 }
588 586
589 } // namespace policy 587 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698