aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2016-02-10 11:28:16 -0800
committerVitaly Buka <vitalybuka@google.com>2016-02-10 22:07:23 +0000
commit1e019fadf76e4ed686fffbbd7bbceb28f5b3c75e (patch)
tree29e7807d74dff49b59dd60f90a52e04de0064731
parent03ee8acf44ca0b46617183ff68da667bd6119993 (diff)
downloadlibweave-1e019fadf76e4ed686fffbbd7bbceb28f5b3c75e.tar.gz
Replace URL with Url in identifiers
Change-Id: I7189f2d49a0b5a3f800f78c4dd53ff4bc1e201b9 Reviewed-on: https://weave-review.googlesource.com/2590 Reviewed-by: Alex Vakulenko <avakulenko@google.com>
-rw-r--r--src/config.cc12
-rw-r--r--src/device_registration_info.cc36
-rw-r--r--src/device_registration_info.h8
-rw-r--r--src/device_registration_info_unittest.cc42
4 files changed, 49 insertions, 49 deletions
diff --git a/src/config.cc b/src/config.cc
index 5ae3fed..cd28de9 100644
--- a/src/config.cc
+++ b/src/config.cc
@@ -31,8 +31,8 @@ const char kVersion[] = "version";
const char kClientId[] = "client_id";
const char kClientSecret[] = "client_secret";
const char kApiKey[] = "api_key";
-const char kOAuthURL[] = "oauth_url";
-const char kServiceURL[] = "service_url";
+const char kOAuthUrl[] = "oauth_url";
+const char kServiceUrl[] = "service_url";
const char kXmppEndpoint[] = "xmpp_endpoint";
const char kName[] = "name";
const char kDescription[] = "description";
@@ -185,10 +185,10 @@ void Config::Transaction::LoadState() {
if (dict->GetString(config_keys::kApiKey, &tmp))
set_api_key(tmp);
- if (dict->GetString(config_keys::kOAuthURL, &tmp))
+ if (dict->GetString(config_keys::kOAuthUrl, &tmp))
set_oauth_url(tmp);
- if (dict->GetString(config_keys::kServiceURL, &tmp)) {
+ if (dict->GetString(config_keys::kServiceUrl, &tmp)) {
if (tmp == kDeprecatedUrl)
tmp = kWeaveUrl;
set_service_url(tmp);
@@ -255,8 +255,8 @@ void Config::Save() {
dict.SetString(config_keys::kClientId, settings_.client_id);
dict.SetString(config_keys::kClientSecret, settings_.client_secret);
dict.SetString(config_keys::kApiKey, settings_.api_key);
- dict.SetString(config_keys::kOAuthURL, settings_.oauth_url);
- dict.SetString(config_keys::kServiceURL, settings_.service_url);
+ dict.SetString(config_keys::kOAuthUrl, settings_.oauth_url);
+ dict.SetString(config_keys::kServiceUrl, settings_.service_url);
dict.SetString(config_keys::kXmppEndpoint, settings_.xmpp_endpoint);
dict.SetString(config_keys::kRefreshToken, settings_.refresh_token);
dict.SetString(config_keys::kCloudId, settings_.cloud_id);
diff --git a/src/device_registration_info.cc b/src/device_registration_info.cc
index b692f06..3ae1321 100644
--- a/src/device_registration_info.cc
+++ b/src/device_registration_info.cc
@@ -91,7 +91,7 @@ std::string AppendQueryParams(const std::string& url,
return url + '?' + WebParamsEncode(params);
}
-std::string BuildURL(const std::string& url,
+std::string BuildUrl(const std::string& url,
const std::string& subpath,
const WebParamList& params) {
std::string result = url;
@@ -272,24 +272,24 @@ DeviceRegistrationInfo::DeviceRegistrationInfo(
DeviceRegistrationInfo::~DeviceRegistrationInfo() = default;
-std::string DeviceRegistrationInfo::GetServiceURL(
+std::string DeviceRegistrationInfo::GetServiceUrl(
const std::string& subpath,
const WebParamList& params) const {
- return BuildURL(GetSettings().service_url, subpath, params);
+ return BuildUrl(GetSettings().service_url, subpath, params);
}
-std::string DeviceRegistrationInfo::GetDeviceURL(
+std::string DeviceRegistrationInfo::GetDeviceUrl(
const std::string& subpath,
const WebParamList& params) const {
CHECK(!GetSettings().cloud_id.empty()) << "Must have a valid device ID";
- return GetServiceURL("devices/" + GetSettings().cloud_id + "/" + subpath,
+ return GetServiceUrl("devices/" + GetSettings().cloud_id + "/" + subpath,
params);
}
-std::string DeviceRegistrationInfo::GetOAuthURL(
+std::string DeviceRegistrationInfo::GetOAuthUrl(
const std::string& subpath,
const WebParamList& params) const {
- return BuildURL(GetSettings().oauth_url, subpath, params);
+ return BuildUrl(GetSettings().oauth_url, subpath, params);
}
void DeviceRegistrationInfo::Start() {
@@ -376,7 +376,7 @@ void DeviceRegistrationInfo::RefreshAccessToken(const DoneCallback& callback) {
return;
}
- RequestSender sender{HttpClient::Method::kPost, GetOAuthURL("token"),
+ RequestSender sender{HttpClient::Method::kPost, GetOAuthUrl("token"),
http_client_};
sender.SetFormData({
{"refresh_token", GetSettings().refresh_token},
@@ -507,7 +507,7 @@ void DeviceRegistrationInfo::GetDeviceInfo(
ErrorPtr error;
if (!VerifyRegistrationCredentials(&error))
return callback.Run({}, std::move(error));
- DoCloudRequest(HttpClient::Method::kGet, GetDeviceURL(), nullptr, callback);
+ DoCloudRequest(HttpClient::Method::kGet, GetDeviceUrl(), nullptr, callback);
}
void DeviceRegistrationInfo::RegisterDeviceError(const DoneCallback& callback,
@@ -572,7 +572,7 @@ void DeviceRegistrationInfo::RegisterDevice(RegistrationData registration_data,
req_json.SetString("oauthClientId", registration_data.client_id);
req_json.Set("deviceDraft", device_draft.release());
- auto url = BuildURL(registration_data.service_url,
+ auto url = BuildUrl(registration_data.service_url,
"registrationTickets/" + registration_data.ticket_id,
{{"key", registration_data.api_key}});
@@ -599,7 +599,7 @@ void DeviceRegistrationInfo::RegisterDeviceOnTicketSent(
return RegisterDeviceError(callback, std::move(error));
}
- std::string url = BuildURL(
+ std::string url = BuildUrl(
registration_data.service_url,
"registrationTickets/" + registration_data.ticket_id + "/finalize",
{{"key", registration_data.api_key}});
@@ -640,7 +640,7 @@ void DeviceRegistrationInfo::RegisterDeviceOnTicketFinalized(
// Now get access_token and refresh_token
RequestSender sender2{HttpClient::Method::kPost,
- BuildURL(registration_data.oauth_url, "token", {}),
+ BuildUrl(registration_data.oauth_url, "token", {}),
http_client_};
sender2.SetFormData({{"code", auth_code},
{"client_id", registration_data.client_id},
@@ -888,7 +888,7 @@ void DeviceRegistrationInfo::UpdateCommand(
const base::DictionaryValue& command_patch,
const DoneCallback& callback) {
DoCloudRequest(HttpClient::Method::kPatch,
- GetServiceURL("commands/" + command_id), &command_patch,
+ GetServiceUrl("commands/" + command_id), &command_patch,
base::Bind(&IgnoreCloudResultWithCallback, callback));
}
@@ -942,7 +942,7 @@ void DeviceRegistrationInfo::StartQueuedUpdateDeviceResource() {
BuildDeviceResource();
CHECK(device_resource);
- std::string url = GetDeviceURL(
+ std::string url = GetDeviceUrl(
{}, {{"lastUpdateTimeMs", last_device_resource_updated_timestamp_}});
DoCloudRequest(HttpClient::Method::kPut, url, device_resource.get(),
@@ -978,7 +978,7 @@ void DeviceRegistrationInfo::SendAuthInfo() {
std::unique_ptr<base::DictionaryValue> root{new base::DictionaryValue};
root->Set("localAuthInfo", auth.release());
- std::string url = GetDeviceURL("upsertLocalAuthInfo", {});
+ std::string url = GetDeviceUrl("upsertLocalAuthInfo", {});
DoCloudRequest(HttpClient::Method::kPost, url, root.get(),
base::Bind(&DeviceRegistrationInfo::OnSendAuthInfoDone,
AsWeakPtr(), token));
@@ -1085,7 +1085,7 @@ void DeviceRegistrationInfo::FetchCommands(
fetch_commands_request_queued_ = false;
DoCloudRequest(
HttpClient::Method::kGet,
- GetServiceURL("commands/queue",
+ GetServiceUrl("commands/queue",
{{"deviceId", GetSettings().cloud_id}, {"reason", reason}}),
nullptr, base::Bind(&DeviceRegistrationInfo::OnFetchCommandsDone,
AsWeakPtr(), callback));
@@ -1133,7 +1133,7 @@ void DeviceRegistrationInfo::ProcessInitialCommandList(
cmd_copy->SetString("state", "aborted");
// TODO(wiley) We could consider handling this error case more gracefully.
DoCloudRequest(HttpClient::Method::kPut,
- GetServiceURL("commands/" + command_id), cmd_copy.get(),
+ GetServiceUrl("commands/" + command_id), cmd_copy.get(),
base::Bind(&IgnoreCloudResult));
} else {
// Normal command, publish it to local clients.
@@ -1211,7 +1211,7 @@ void DeviceRegistrationInfo::PublishStateUpdates() {
body.Set("patches", patches.release());
device_state_update_pending_ = true;
- DoCloudRequest(HttpClient::Method::kPost, GetDeviceURL("patchState"), &body,
+ DoCloudRequest(HttpClient::Method::kPost, GetDeviceUrl("patchState"), &body,
base::Bind(&DeviceRegistrationInfo::OnPublishStateDone,
AsWeakPtr(), snapshot.update_id));
}
diff --git a/src/device_registration_info.h b/src/device_registration_info.h
index ef79268..a488bae 100644
--- a/src/device_registration_info.h
+++ b/src/device_registration_info.h
@@ -84,21 +84,21 @@ class DeviceRegistrationInfo : public NotificationDelegate,
// WebParamsEncode() and appended to URL as a query
// string.
// So, calling:
- // GetServiceURL("ticket", {{"key","apiKey"}})
+ // GetServiceUrl("ticket", {{"key","apiKey"}})
// will return something like:
// https://www.googleapis.com/weave/v1/ticket?key=apiKey
- std::string GetServiceURL(const std::string& subpath = {},
+ std::string GetServiceUrl(const std::string& subpath = {},
const WebParamList& params = {}) const;
// Returns a service URL to access the registered device on GCD server.
// The base URL used to construct the full URL looks like this:
// https://www.googleapis.com/weave/v1/devices/<cloud_id>/
- std::string GetDeviceURL(const std::string& subpath = {},
+ std::string GetDeviceUrl(const std::string& subpath = {},
const WebParamList& params = {}) const;
// Similar to GetServiceURL, GetOAuthURL() returns a URL of OAuth 2.0 server.
// The base URL used is https://accounts.google.com/o/oauth2/.
- std::string GetOAuthURL(const std::string& subpath = {},
+ std::string GetOAuthUrl(const std::string& subpath = {},
const WebParamList& params = {}) const;
// Starts GCD device if credentials available.
diff --git a/src/device_registration_info_unittest.cc b/src/device_registration_info_unittest.cc
index d3d0c26..adc5175 100644
--- a/src/device_registration_info_unittest.cc
+++ b/src/device_registration_info_unittest.cc
@@ -45,8 +45,8 @@ namespace {
namespace test_data {
const char kXmppEndpoint[] = "xmpp.server.com:1234";
-const char kServiceURL[] = "http://gcd.server.com/";
-const char kOAuthURL[] = "http://oauth.server.com/";
+const char kServiceUrl[] = "http://gcd.server.com/";
+const char kOAuthUrl[] = "http://oauth.server.com/";
const char kApiKey[] = "GOadRdTf9FERf0k4w6EFOof56fUJ3kFDdFL3d7f";
const char kClientId[] =
"123543821385-sfjkjshdkjhfk234sdfsdfkskd"
@@ -143,8 +143,8 @@ class DeviceRegistrationInfoTest : public ::testing::Test {
settings->location = "Kitchen";
settings->local_anonymous_access_role = AuthScope::kViewer;
settings->model_id = "AAAAA";
- settings->oauth_url = test_data::kOAuthURL;
- settings->service_url = test_data::kServiceURL;
+ settings->oauth_url = test_data::kOAuthUrl;
+ settings->service_url = test_data::kServiceUrl;
settings->xmpp_endpoint = test_data::kXmppEndpoint;
settings->allow_endpoints_override = allow_endpoints_override;
return true;
@@ -217,31 +217,31 @@ class DeviceRegistrationInfoTest : public ::testing::Test {
ComponentManagerImpl component_manager_{&task_runner_};
};
-TEST_F(DeviceRegistrationInfoTest, GetServiceURL) {
- EXPECT_EQ(test_data::kServiceURL, dev_reg_->GetServiceURL());
- std::string url = test_data::kServiceURL;
+TEST_F(DeviceRegistrationInfoTest, GetServiceUrl) {
+ EXPECT_EQ(test_data::kServiceUrl, dev_reg_->GetServiceUrl());
+ std::string url = test_data::kServiceUrl;
url += "registrationTickets";
- EXPECT_EQ(url, dev_reg_->GetServiceURL("registrationTickets"));
+ EXPECT_EQ(url, dev_reg_->GetServiceUrl("registrationTickets"));
url += "?key=";
url += test_data::kApiKey;
- EXPECT_EQ(url, dev_reg_->GetServiceURL("registrationTickets",
+ EXPECT_EQ(url, dev_reg_->GetServiceUrl("registrationTickets",
{{"key", test_data::kApiKey}}));
url += "&restart=true";
- EXPECT_EQ(url, dev_reg_->GetServiceURL(
+ EXPECT_EQ(url, dev_reg_->GetServiceUrl(
"registrationTickets",
{
{"key", test_data::kApiKey}, {"restart", "true"},
}));
}
-TEST_F(DeviceRegistrationInfoTest, GetOAuthURL) {
- EXPECT_EQ(test_data::kOAuthURL, dev_reg_->GetOAuthURL());
- std::string url = test_data::kOAuthURL;
+TEST_F(DeviceRegistrationInfoTest, GetOAuthUrl) {
+ EXPECT_EQ(test_data::kOAuthUrl, dev_reg_->GetOAuthUrl());
+ std::string url = test_data::kOAuthUrl;
url += "auth?redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&";
url += "response_type=code&";
url += "client_id=";
url += test_data::kClientId;
- EXPECT_EQ(url, dev_reg_->GetOAuthURL(
+ EXPECT_EQ(url, dev_reg_->GetOAuthUrl(
"auth", {{"redirect_uri", "urn:ietf:wg:oauth:2.0:oob"},
{"response_type", "code"},
{"client_id", test_data::kClientId}}));
@@ -253,7 +253,7 @@ TEST_F(DeviceRegistrationInfoTest, HaveRegistrationCredentials) {
EXPECT_CALL(
http_client_,
- SendRequest(HttpClient::Method::kPost, dev_reg_->GetOAuthURL("token"),
+ SendRequest(HttpClient::Method::kPost, dev_reg_->GetOAuthUrl("token"),
HttpClient::Headers{GetFormHeader()}, _, _))
.WillOnce(WithArgs<3, 4>(
Invoke([](const std::string& data,
@@ -296,7 +296,7 @@ TEST_F(DeviceRegistrationInfoTest, CheckAuthenticationFailure) {
EXPECT_CALL(
http_client_,
- SendRequest(HttpClient::Method::kPost, dev_reg_->GetOAuthURL("token"),
+ SendRequest(HttpClient::Method::kPost, dev_reg_->GetOAuthUrl("token"),
HttpClient::Headers{GetFormHeader()}, _, _))
.WillOnce(WithArgs<3, 4>(
Invoke([](const std::string& data,
@@ -325,7 +325,7 @@ TEST_F(DeviceRegistrationInfoTest, CheckDeregistration) {
EXPECT_CALL(
http_client_,
- SendRequest(HttpClient::Method::kPost, dev_reg_->GetOAuthURL("token"),
+ SendRequest(HttpClient::Method::kPost, dev_reg_->GetOAuthUrl("token"),
HttpClient::Headers{GetFormHeader()}, _, _))
.WillOnce(WithArgs<3, 4>(
Invoke([](const std::string& data,
@@ -355,7 +355,7 @@ TEST_F(DeviceRegistrationInfoTest, GetDeviceInfo) {
EXPECT_CALL(
http_client_,
- SendRequest(HttpClient::Method::kGet, dev_reg_->GetDeviceURL(),
+ SendRequest(HttpClient::Method::kGet, dev_reg_->GetDeviceUrl(),
HttpClient::Headers{GetAuthHeader(), GetJsonHeader()}, _, _))
.WillOnce(WithArgs<3, 4>(
Invoke([](const std::string& data,
@@ -625,11 +625,11 @@ TEST_F(DeviceRegistrationInfoTest, RegisterDeviceWithDefaultEndpoints) {
registration_data.ticket_id = "test_ticked_id";
RegistrationData expected_data = registration_data;
- expected_data.oauth_url = test_data::kOAuthURL;
+ expected_data.oauth_url = test_data::kOAuthUrl;
expected_data.client_id = test_data::kClientId;
expected_data.client_secret = test_data::kClientSecret;
expected_data.api_key = test_data::kApiKey;
- expected_data.service_url = test_data::kServiceURL;
+ expected_data.service_url = test_data::kServiceUrl;
expected_data.xmpp_endpoint = test_data::kXmppEndpoint;
RegisterDevice(registration_data, expected_data);
@@ -687,7 +687,7 @@ class DeviceRegistrationInfoUpdateCommandTest
EXPECT_TRUE(
component_manager_.AddComponent("", "comp", {"robot"}, nullptr));
- command_url_ = dev_reg_->GetServiceURL("commands/1234");
+ command_url_ = dev_reg_->GetServiceUrl("commands/1234");
auto commands_json = CreateValue(R"([{
'name':'robot._jump',