Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 15: Set the fallback URL for google extensions/components to componentupdater.brave.com. #16

Merged
merged 1 commit into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func UpdateExtensions(w http.ResponseWriter, r *http.Request) {
if len(r.URL.RawQuery) != 0 {
queryString = r.URL.RawQuery + "&" + queryString
}
http.Redirect(w, r, "https://update.googleapis.com/service/update2?"+queryString, http.StatusTemporaryRedirect)
http.Redirect(w, r, "https://componentupdater.brave.com/service/update2?"+queryString, http.StatusTemporaryRedirect)
return
}
}
Expand Down
9 changes: 5 additions & 4 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,16 @@ func TestUpdateExtensions(t *testing.T) {
</response>`
testCall(t, server, http.MethodPost, "", requestBody, http.StatusOK, expectedResponse, "")

// Unkonwn extension ID goes to Google server
// Unkonwn extension ID goes to Google server via componentupdater proxy
requestBody = extensiontest.ExtensionRequestFnFor("aaaaaaaaaaaaaaaaaaaa")("0.0.0")
expectedResponse = ""
testCall(t, server, http.MethodPost, "", requestBody, http.StatusTemporaryRedirect, expectedResponse, "https://update.googleapis.com/service/update2?braveRedirect=true")
testCall(t, server, http.MethodPost, "", requestBody, http.StatusTemporaryRedirect, expectedResponse, "https://componentupdater.brave.com/service/update2?braveRedirect=true")

// Unkonwn extension ID goes to Google server and preserves queyr params
// Unkonwn extension ID goes to Google server via componentupdater proxy
// and preserves query params
requestBody = extensiontest.ExtensionRequestFnFor("aaaaaaaaaaaaaaaaaaaa")("0.0.0")
expectedResponse = ""
testCall(t, server, http.MethodPost, "?test=hi", requestBody, http.StatusTemporaryRedirect, expectedResponse, "https://update.googleapis.com/service/update2?test=hi&braveRedirect=true")
testCall(t, server, http.MethodPost, "?test=hi", requestBody, http.StatusTemporaryRedirect, expectedResponse, "https://componentupdater.brave.com/service/update2?test=hi&braveRedirect=true")

// Make sure a huge request body does not crash the server
data := make([]byte, 1024*1024*11) // 11 MiB
Expand Down