Commit b9fbd971 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

3 more tests added to network traffic annotation auditor unittest.

Annotation and call deserialization and duplicate code checking added to
network traffic annotation auditor's unittest.

Bug: 656607
Bug: 690323
Change-Id: I4397359da0c170f9fe9a1dda0bcc57ef723ed863
Reviewed-on: https://chromium-review.googlesource.com/568034
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486704}
parent ffc67cf8
headless/public/util/http_url_fetcher.cc
headless::HttpURLFetcher::Delegate::Delegate
net::URLRequestContext::CreateRequest
1
\ No newline at end of file
chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fetcher.cc
OnGetTokenSuccess
166
Definition
supervised_user_refresh_token_fetcher
semantics
sender: "Supervised Users"
description:
"Fetches an OAuth2 refresh token scoped down to the Supervised "
"User Sync scope and tied to the given Supervised User ID, "
"identifying the Supervised User Profile to be created."
trigger:
"Called when creating a new Supervised User profile in Chromium "
"to fetch OAuth credentials for using Sync with the new profile."
data:
"The request is authenticated with an OAuth2 access token "
"identifying the Google account and contains the following "
"information:\n* The Supervised User ID, a randomly generated "
"64-bit identifier for the profile.\n* The device name, to "
"identify the refresh token in account management."
destination: GOOGLE_OWNED_SERVICE
}
policy {
cookies_allowed: false
setting:
"Users can disable this feature by toggling 'Let anyone add a "
"person to Chrome' in Chromium settings, under People."
chrome_policy {
SupervisedUserCreationEnabled {
policy_options {mode: MANDATORY}
SupervisedUserCreationEnabled: false
}
}
}
\ No newline at end of file
chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fetcher.cc
OnGetTokenSuccess
166
Definition
supervised_user_refresh_token_fetcher
Semantics {
sender: "Supervised Users"
description:
"Fetches an OAuth2 refresh token scoped down to the Supervised "
"User Sync scope and tied to the given Supervised User ID, "
"identifying the Supervised User Profile to be created."
trigger:
"Called when creating a new Supervised User profile in Chromium "
"to fetch OAuth credentials for using Sync with the new profile."
data:
"The request is authenticated with an OAuth2 access token "
"identifying the Google account and contains the following "
"information:\n* The Supervised User ID, a randomly generated "
"64-bit identifier for the profile.\n* The device name, to "
"identify the refresh token in account management."
destination: GOOGLE_OWNED_SERVICE
}
policy {
cookies_allowed: false
setting:
"Users can disable this feature by toggling 'Let anyone add a "
"person to Chrome' in Chromium settings, under People."
chrome_policy {
SupervisedUserCreationEnabled {
policy_options {mode: MANDATORY}
SupervisedUserCreationEnabled: false
}
}
}
\ No newline at end of file
chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fetcher.cc
OnGetTokenSuccess
166
Definition
supervised_user_refresh_token_fetcher
Semantics {
sender: "Supervised Users
description:
"Fetches an OAuth2 refresh token scoped down to the Supervised "
"User Sync scope and tied to the given Supervised User ID, "
"identifying the Supervised User Profile to be created."
trigger:
"Called when creating a new Supervised User profile in Chromium "
"to fetch OAuth credentials for using Sync with the new profile."
data:
"The request is authenticated with an OAuth2 access token "
"identifying the Google account and contains the following "
"information:\n* The Supervised User ID, a randomly generated "
"64-bit identifier for the profile.\n* The device name, to "
"identify the refresh token in account management."
destination: GOOGLE_OWNED_SERVICE
}
policy {
cookies_allowed: false
setting:
"Users can disable this feature by toggling 'Let anyone add a "
"person to Chrome' in Chromium settings, under People."
chrome_policy {
SupervisedUserCreationEnabled {
policy_options {mode: MANDATORY}
SupervisedUserCreationEnabled: false
}
}
}
\ No newline at end of file
chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fetcher.cc
OnGetTokenSuccess
166
Definition
supervised_user_refresh_token_fetcher
Semantics {
sender: "Supervised Users
description:
"Fetches an OAuth2 refresh token scoped down to the Supervised "
"User Sync scope and tied to the given Supervised User ID, "
"identifying the Supervised User Profile to be created."
trigger:
"Called when creating a new Supervised User profile in Chromium "
"to fetch OAuth credentials for using Sync with the new profile."
data:
"The request is authenticated with an OAuth2 access token "
"identifying the Google account and contains the following "
"information:\n* The Supervised User ID, a randomly generated "
"64-bit identifier for the profile.\n* The device name, to "
"identify the refresh token in account management."
destination: GOOGLE_OWNED_SERVICE
cookies_allowed: false
setting:
"Users can disable this feature by toggling 'Let anyone add a "
"person to Chrome' in Chromium settings, under People."
chrome_policy {
SupervisedUserCreationEnabled {
policy_options {mode: MANDATORY}
SupervisedUserCreationEnabled: false
}
}
}
\ No newline at end of file
chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fetcher.cc
OnGetTokenSuccess
Definition
supervised_user_refresh_token_fetcher
semantics {
sender: "Supervised Users"
description:
"Fetches an OAuth2 refresh token scoped down to the Supervised "
"User Sync scope and tied to the given Supervised User ID, "
"identifying the Supervised User Profile to be created."
trigger:
"Called when creating a new Supervised User profile in Chromium "
"to fetch OAuth credentials for using Sync with the new profile."
data:
"The request is authenticated with an OAuth2 access token "
"identifying the Google account and contains the following "
"information:\n* The Supervised User ID, a randomly generated "
"64-bit identifier for the profile.\n* The device name, to "
"identify the refresh token in account management."
destination: GOOGLE_OWNED_SERVICE
}
policy {
cookies_allowed: false
setting:
"Users can disable this feature by toggling 'Let anyone add a "
"person to Chrome' in Chromium settings, under People."
chrome_policy {
SupervisedUserCreationEnabled {
policy_options {mode: MANDATORY}
SupervisedUserCreationEnabled: false
}
}
}
\ No newline at end of file
chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fetcher.cc
OnGetTokenSuccess
122
definition
supervised_user_refresh_token_fetcher
semantics {
sender: "Supervised Users"
description:
"Fetches an OAuth2 refresh token scoped down to the Supervised "
"User Sync scope and tied to the given Supervised User ID, "
"identifying the Supervised User Profile to be created."
trigger:
"Called when creating a new Supervised User profile in Chromium "
"to fetch OAuth credentials for using Sync with the new profile."
data:
"The request is authenticated with an OAuth2 access token "
"identifying the Google account and contains the following "
"information:\n* The Supervised User ID, a randomly generated "
"64-bit identifier for the profile.\n* The device name, to "
"identify the refresh token in account management."
destination: GOOGLE_OWNED_SERVICE
}
policy {
cookies_allowed: false
setting:
"Users can disable this feature by toggling 'Let anyone add a "
"person to Chrome' in Chromium settings, under People."
chrome_policy {
SupervisedUserCreationEnabled {
policy_options {mode: MANDATORY}
SupervisedUserCreationEnabled: false
}
}
}
\ No newline at end of file
chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fetcher.cc
OnGetTokenSuccess
122
definition
supervised_user_refresh_token_fetcher
chrome/service/cloud_print/cloud_print_url_fetcher.cc
cloud_print::CloudPrintURLFetcher::StartRequestHelper
265
BranchedCompleting
cloud_print
semantics {
sender: "Cloud Print"
destination: GOOGLE_OWNED_SERVICE
}
policy {
cookies_allowed: false
setting:
"This feature cannot be disabled by settings."
chrome_policy {
CloudPrintProxyEnabled {
policy_options {mode: MANDATORY}
CloudPrintProxyEnabled: false
}
}
}
\ No newline at end of file
headless/public/util/http_url_fetcher.cc
headless::HttpURLFetcher::Delegate::Delegate
100
net::URLRequestContext::CreateRequest
1
\ No newline at end of file
chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fetcher.cc
OnGetTokenSuccess
166
Definition
supervised_user_refresh_token_fetcher
semantics {
sender: "Supervised Users"
description:
"Fetches an OAuth2 refresh token scoped down to the Supervised "
"User Sync scope and tied to the given Supervised User ID, "
"identifying the Supervised User Profile to be created."
trigger:
"Called when creating a new Supervised User profile in Chromium "
"to fetch OAuth credentials for using Sync with the new profile."
data:
"The request is authenticated with an OAuth2 access token "
"identifying the Google account and contains the following "
"information:\n* The Supervised User ID, a randomly generated "
"64-bit identifier for the profile.\n* The device name, to "
"identify the refresh token in account management."
destination: GOOGLE_OWNED_SERVICE
}
policy {
cookies_allowed: false
setting:
"Users can disable this feature by toggling 'Let anyone add a "
"person to Chrome' in Chromium settings, under People."
chrome_policy {
SupervisedUserCreationEnabled {
policy_options {mode: MANDATORY}
SupervisedUserCreationEnabled: false
}
}
}
\ No newline at end of file
chrome/service/cloud_print/cloud_print_url_fetcher.cc
cloud_print::CloudPrintURLFetcher::StartRequestHelper
265
Completing
cloud_print
semantics {
sender: "Cloud Print"
destination: GOOGLE_OWNED_SERVICE
}
policy {
cookies_allowed: false
setting:
"This feature cannot be disabled by settings."
chrome_policy {
CloudPrintProxyEnabled {
policy_options {mode: MANDATORY}
CloudPrintProxyEnabled: false
}
}
}
\ No newline at end of file
components/browsing_data/core/counters/history_counter.cc
browsing_data::HistoryCounter::Count
98
Partial
web_history_counter
web_history_service
semantics {
description:
"If history sync is enabled, this queries history.google.com to "
"determine if there is any synced history. This information is "
"displayed in the Clear Browsing Data dialog."
trigger:
"Checking the 'Browsing history' option in the Clear Browsing Data "
"dialog, or enabling history sync while the dialog is open."
data:
"A version info token to resolve transaction conflicts, and an "
"OAuth2 token authenticating the user."
}
policy {
chrome_policy {
SyncDisabled {
SyncDisabled: true
}
}
}
\ No newline at end of file
google_apis/drive/request_sender_unittest.cc
google_apis::(anonymous namespace)::RequestSenderTest::RequestSenderTest
67
Definition
test
Traffic annotation for unit, browser and other tests
\ No newline at end of file
net/url_request/url_request_context.cc
net::URLRequestContext::CreateRequest
120
Definition
missing
Function called without traffic annotation.
components/download/internal/controller_impl.cc
download::ControllerImpl::UpdateDriverState
656
Definition
undefined
Nothing here yet.
\ No newline at end of file
...@@ -506,6 +506,7 @@ bool TrafficAnnotationAuditor::LoadWhiteList() { ...@@ -506,6 +506,7 @@ bool TrafficAnnotationAuditor::LoadWhiteList() {
return false; return false;
} }
// static
const std::map<int, std::string>& const std::map<int, std::string>&
TrafficAnnotationAuditor::GetReservedUniqueIDs() { TrafficAnnotationAuditor::GetReservedUniqueIDs() {
return kReservedAnnotations; return kReservedAnnotations;
......
...@@ -83,9 +83,20 @@ class AuditorResult { ...@@ -83,9 +83,20 @@ class AuditorResult {
int line_; int line_;
}; };
// Base class for Annotation and Call instances.
class InstanceBase {
public:
InstanceBase(){};
virtual ~InstanceBase(){};
virtual AuditorResult Deserialize(
const std::vector<std::string>& serialized_lines,
int start_line,
int end_line) = 0;
};
// Holds an instance of network traffic annotation. // Holds an instance of network traffic annotation.
// TODO(rhalavati): Check if this class can also be reused in clang tool. // TODO(rhalavati): Check if this class can also be reused in clang tool.
class AnnotationInstance { class AnnotationInstance : public InstanceBase {
public: public:
// Annotation Type. // Annotation Type.
enum class AnnotationType { enum class AnnotationType {
...@@ -115,7 +126,7 @@ class AnnotationInstance { ...@@ -115,7 +126,7 @@ class AnnotationInstance {
// FATAL, furthur processing of the text should be stopped. // FATAL, furthur processing of the text should be stopped.
AuditorResult Deserialize(const std::vector<std::string>& serialized_lines, AuditorResult Deserialize(const std::vector<std::string>& serialized_lines,
int start_line, int start_line,
int end_line); int end_line) override;
// Protobuf of the annotation. // Protobuf of the annotation.
traffic_annotation::NetworkTrafficAnnotation proto; traffic_annotation::NetworkTrafficAnnotation proto;
...@@ -134,7 +145,7 @@ class AnnotationInstance { ...@@ -134,7 +145,7 @@ class AnnotationInstance {
// Holds an instance of calling a function that might have a network traffic // Holds an instance of calling a function that might have a network traffic
// annotation argument. // annotation argument.
// TODO(rhalavati): Check if this class can also be reused in clang tool. // TODO(rhalavati): Check if this class can also be reused in clang tool.
class CallInstance { class CallInstance : public InstanceBase {
public: public:
CallInstance(); CallInstance();
CallInstance(const CallInstance& other); CallInstance(const CallInstance& other);
...@@ -152,7 +163,7 @@ class CallInstance { ...@@ -152,7 +163,7 @@ class CallInstance {
// FATAL, further processing of the text should be stopped. // FATAL, further processing of the text should be stopped.
AuditorResult Deserialize(const std::vector<std::string>& serialized_lines, AuditorResult Deserialize(const std::vector<std::string>& serialized_lines,
int start_line, int start_line,
int end_line); int end_line) override;
std::string file_path; std::string file_path;
uint32_t line_number; uint32_t line_number;
...@@ -205,7 +216,7 @@ class TrafficAnnotationAuditor { ...@@ -205,7 +216,7 @@ class TrafficAnnotationAuditor {
// texts. This list includes all unique ids that are defined in // texts. This list includes all unique ids that are defined in
// net/traffic_annotation/network_traffic_annotation.h and // net/traffic_annotation/network_traffic_annotation.h and
// net/traffic_annotation/network_traffic_annotation_test_helper.h // net/traffic_annotation/network_traffic_annotation_test_helper.h
const std::map<int, std::string>& GetReservedUniqueIDs(); static const std::map<int, std::string>& GetReservedUniqueIDs();
std::string clang_tool_raw_output() const { return clang_tool_raw_output_; }; std::string clang_tool_raw_output() const { return clang_tool_raw_output_; };
...@@ -217,14 +228,20 @@ class TrafficAnnotationAuditor { ...@@ -217,14 +228,20 @@ class TrafficAnnotationAuditor {
return extracted_annotations_; return extracted_annotations_;
} }
void SetExtractedAnnotationsForTest(
const std::vector<AnnotationInstance>& annotations) {
extracted_annotations_ = annotations;
}
const std::vector<CallInstance>& extracted_calls() const { const std::vector<CallInstance>& extracted_calls() const {
return extracted_calls_; return extracted_calls_;
} }
const std::vector<AuditorResult>& errors() const { return errors_; } const std::vector<AuditorResult>& errors() const { return errors_; }
private: void ClearErrorsForTest() { errors_.clear(); }
private:
const base::FilePath source_path_; const base::FilePath source_path_;
const base::FilePath build_path_; const base::FilePath build_path_;
......
...@@ -183,7 +183,7 @@ int main(int argc, char* argv[]) { ...@@ -183,7 +183,7 @@ int main(int argc, char* argv[]) {
} }
const std::map<int, std::string> reserved_ids = const std::map<int, std::string> reserved_ids =
auditor.GetReservedUniqueIDs(); TrafficAnnotationAuditor::GetReservedUniqueIDs();
for (const auto& item : reserved_ids) for (const auto& item : reserved_ids)
items.push_back(item); items.push_back(item);
......
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