Commit 12b295bb authored by Sergey Poromov's avatar Sergey Poromov Committed by Commit Bot

Remove unused CloudPolicyService::ManagedBy()

This function was extracting domain from username in PolicyData
which could be not up-to-date after domain rename.
It's better to get rid of as much |username| usages as possible.

BUG=780792
TEST=Trybots

Change-Id: I6aba952cb63d4450863ac7f3ee30c18a3a9830d1
Reviewed-on: https://chromium-review.googlesource.com/1017122Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551761}
parent 75d33ec6
...@@ -43,17 +43,6 @@ CloudPolicyService::~CloudPolicyService() { ...@@ -43,17 +43,6 @@ CloudPolicyService::~CloudPolicyService() {
store_->RemoveObserver(this); store_->RemoveObserver(this);
} }
std::string CloudPolicyService::ManagedBy() const {
const em::PolicyData* policy = store_->policy();
if (policy) {
std::string username = policy->username();
std::size_t pos = username.find('@');
if (pos != std::string::npos)
return username.substr(pos + 1);
}
return std::string();
}
void CloudPolicyService::RefreshPolicy(const RefreshPolicyCallback& callback) { void CloudPolicyService::RefreshPolicy(const RefreshPolicyCallback& callback) {
// If the client is not registered or is unregistering, bail out. // If the client is not registered or is unregistering, bail out.
if (!client_->is_registered() || unregister_state_ != UNREGISTER_NONE) { if (!client_->is_registered() || unregister_state_ != UNREGISTER_NONE) {
......
...@@ -48,10 +48,6 @@ class POLICY_EXPORT CloudPolicyService : public CloudPolicyClient::Observer, ...@@ -48,10 +48,6 @@ class POLICY_EXPORT CloudPolicyService : public CloudPolicyClient::Observer,
CloudPolicyStore* store); CloudPolicyStore* store);
~CloudPolicyService() override; ~CloudPolicyService() override;
// Returns the domain that manages this user/device, according to the current
// policy blob. Empty if not managed/not available.
std::string ManagedBy() const;
// Refreshes policy. |callback| will be invoked after the operation completes // Refreshes policy. |callback| will be invoked after the operation completes
// or aborts because of errors. // or aborts because of errors.
void RefreshPolicy(const RefreshPolicyCallback& callback); void RefreshPolicy(const RefreshPolicyCallback& callback);
......
...@@ -51,16 +51,6 @@ MATCHER_P(ProtoMatches, proto, std::string()) { ...@@ -51,16 +51,6 @@ MATCHER_P(ProtoMatches, proto, std::string()) {
return arg.SerializePartialAsString() == proto.SerializePartialAsString(); return arg.SerializePartialAsString() == proto.SerializePartialAsString();
} }
TEST_F(CloudPolicyServiceTest, ManagedByEmptyPolicy) {
EXPECT_EQ(std::string(), service_.ManagedBy());
}
TEST_F(CloudPolicyServiceTest, ManagedByValidPolicy) {
store_.policy_.reset(new em::PolicyData());
store_.policy_->set_username("user@example.com");
EXPECT_EQ("example.com", service_.ManagedBy());
}
TEST_F(CloudPolicyServiceTest, PolicyUpdateSuccess) { TEST_F(CloudPolicyServiceTest, PolicyUpdateSuccess) {
em::PolicyFetchResponse policy; em::PolicyFetchResponse policy;
policy.set_policy_data("fake policy"); policy.set_policy_data("fake policy");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment