[MM-42822] Check for and return HTTP 451 for all trial requests (#19873)

* Check for and return HTTP 451 for all trial requests

* Use constant in another spot too

* add a test

* Update test name
Этот коммит содержится в:
Nick Misasi
2022-04-04 09:48:14 -04:00
коммит произвёл GitHub
родитель 7b5ac343f0
Коммит 650ad3b3ae
3 изменённых файлов: 39 добавлений и 0 удалений

Просмотреть файл

@@ -340,6 +340,11 @@ func (s *Server) RequestTrialLicense(trialRequest *model.TrialLicenseRequest) *m
}
defer resp.Body.Close()
// CloudFlare sitting in front of the Customer Portal will block this request with a 451 response code in the event that the request originates from a country sanctioned by the U.S. Government.
if resp.StatusCode == http.StatusUnavailableForLegalReasons {
return model.NewAppError("RequestTrialLicense", "api.license.request_trial_license.embargoed", nil, "Request for trial license came from an embargoed country", http.StatusUnavailableForLegalReasons)
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return model.NewAppError("RequestTrialLicense", "api.license.request_trial_license.app_error", nil,
fmt.Sprintf("Unexpected HTTP status code %q returned by server", resp.Status), http.StatusInternalServerError)