[MM-37755] Idiomatic naming (SMTP, TLS, TCP, XML, CSS, HTML, HTTP) (#18103)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bd65e8daf9
Коммит
fd853e74a6
@@ -52,7 +52,7 @@ func (ad *AccessData) IsValid() *AppError {
|
||||
return NewAppError("AccessData.IsValid", "model.access.is_valid.refresh_token.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if ad.RedirectUri == "" || len(ad.RedirectUri) > 256 || !IsValidHttpUrl(ad.RedirectUri) {
|
||||
if ad.RedirectUri == "" || len(ad.RedirectUri) > 256 || !IsValidHTTPUrl(ad.RedirectUri) {
|
||||
return NewAppError("AccessData.IsValid", "model.access.is_valid.redirect_uri.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ func (ad *AuthData) IsValid() *AppError {
|
||||
return NewAppError("AuthData.IsValid", "model.authorize.is_valid.create_at.app_error", nil, "client_id="+ad.ClientId, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(ad.RedirectUri) > 256 || !IsValidHttpUrl(ad.RedirectUri) {
|
||||
if len(ad.RedirectUri) > 256 || !IsValidHTTPUrl(ad.RedirectUri) {
|
||||
return NewAppError("AuthData.IsValid", "model.authorize.is_valid.redirect_uri.app_error", nil, "client_id="+ad.ClientId, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ func (ar *AuthorizeRequest) IsValid() *AppError {
|
||||
return NewAppError("AuthData.IsValid", "model.authorize.is_valid.response_type.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if ar.RedirectUri == "" || len(ar.RedirectUri) > 256 || !IsValidHttpUrl(ar.RedirectUri) {
|
||||
if ar.RedirectUri == "" || len(ar.RedirectUri) > 256 || !IsValidHTTPUrl(ar.RedirectUri) {
|
||||
return NewAppError("AuthData.IsValid", "model.authorize.is_valid.redirect_uri.app_error", nil, "client_id="+ar.ClientId, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ const (
|
||||
HeaderRemoteclusterToken = "X-RemoteCluster-Token"
|
||||
HeaderRemoteclusterId = "X-RemoteCluster-Id"
|
||||
HeaderRequestedWith = "X-Requested-With"
|
||||
HeaderRequestedWithXml = "XMLHttpRequest"
|
||||
HeaderRequestedWithXML = "XMLHttpRequest"
|
||||
HeaderRange = "Range"
|
||||
STATUS = "status"
|
||||
StatusOk = "OK"
|
||||
@@ -62,10 +62,10 @@ type Response struct {
|
||||
type Client4 struct {
|
||||
Url string // The location of the server, for example "http://localhost:8065"
|
||||
ApiUrl string // The api location of the server, for example "http://localhost:8065/api/v4"
|
||||
HttpClient *http.Client // The http client
|
||||
HTTPClient *http.Client // The http client
|
||||
AuthToken string
|
||||
AuthType string
|
||||
HttpHeader map[string]string // Headers to be copied over for each request
|
||||
HTTPHeader map[string]string // Headers to be copied over for each request
|
||||
|
||||
// TrueString is the string value sent to the server for true boolean query parameters.
|
||||
trueString string
|
||||
@@ -131,7 +131,7 @@ func NewAPIv4SocketClient(socketPath string) *Client4 {
|
||||
}
|
||||
|
||||
client := NewAPIv4Client("http://_")
|
||||
client.HttpClient = &http.Client{Transport: tr}
|
||||
client.HTTPClient = &http.Client{Transport: tr}
|
||||
|
||||
return client
|
||||
}
|
||||
@@ -635,13 +635,13 @@ func (c *Client4) doApiRequestReader(method, url string, data io.Reader, headers
|
||||
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
if c.HttpHeader != nil && len(c.HttpHeader) > 0 {
|
||||
for k, v := range c.HttpHeader {
|
||||
if c.HTTPHeader != nil && len(c.HTTPHeader) > 0 {
|
||||
for k, v := range c.HTTPHeader {
|
||||
rq.Header.Set(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
rp, err := c.HttpClient.Do(rq)
|
||||
rp, err := c.HTTPClient.Do(rq)
|
||||
if err != nil || rp == nil {
|
||||
return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
|
||||
}
|
||||
@@ -676,7 +676,7 @@ func (c *Client4) doUploadFile(url string, body io.Reader, contentType string, c
|
||||
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
rp, err := c.HttpClient.Do(rq)
|
||||
rp, err := c.HTTPClient.Do(rq)
|
||||
if err != nil || rp == nil {
|
||||
return nil, BuildErrorResponse(rp, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0))
|
||||
}
|
||||
@@ -700,7 +700,7 @@ func (c *Client4) DoEmojiUploadFile(url string, data []byte, contentType string)
|
||||
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
rp, err := c.HttpClient.Do(rq)
|
||||
rp, err := c.HTTPClient.Do(rq)
|
||||
if err != nil || rp == nil {
|
||||
return nil, BuildErrorResponse(rp, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0))
|
||||
}
|
||||
@@ -724,7 +724,7 @@ func (c *Client4) DoUploadImportTeam(url string, data []byte, contentType string
|
||||
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
rp, err := c.HttpClient.Do(rq)
|
||||
rp, err := c.HTTPClient.Do(rq)
|
||||
if err != nil || rp == nil {
|
||||
return nil, BuildErrorResponse(rp, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0))
|
||||
}
|
||||
@@ -1566,7 +1566,7 @@ func (c *Client4) SetProfileImage(userId string, data []byte) (bool, *Response)
|
||||
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
rp, err := c.HttpClient.Do(rq)
|
||||
rp, err := c.HTTPClient.Do(rq)
|
||||
if err != nil || rp == nil {
|
||||
return false, &Response{StatusCode: http.StatusForbidden, Error: NewAppError(c.GetUserRoute(userId)+"/image", "model.client.connecting.app_error", nil, err.Error(), http.StatusForbidden)}
|
||||
}
|
||||
@@ -2402,7 +2402,7 @@ func (c *Client4) SetTeamIcon(teamId string, data []byte) (bool, *Response) {
|
||||
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
rp, err := c.HttpClient.Do(rq)
|
||||
rp, err := c.HTTPClient.Do(rq)
|
||||
if err != nil || rp == nil {
|
||||
// set to http.StatusForbidden(403)
|
||||
return false, &Response{StatusCode: http.StatusForbidden, Error: NewAppError(c.GetTeamRoute(teamId)+"/image", "model.client.connecting.app_error", nil, err.Error(), 403)}
|
||||
@@ -3894,7 +3894,7 @@ func (c *Client4) UploadLicenseFile(data []byte) (bool, *Response) {
|
||||
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
rp, err := c.HttpClient.Do(rq)
|
||||
rp, err := c.HTTPClient.Do(rq)
|
||||
if err != nil || rp == nil {
|
||||
return false, &Response{StatusCode: http.StatusForbidden, Error: NewAppError(c.GetLicenseRoute(), "model.client.connecting.app_error", nil, err.Error(), http.StatusForbidden)}
|
||||
}
|
||||
@@ -4357,7 +4357,7 @@ func (c *Client4) DownloadComplianceReport(reportId string) ([]byte, *Response)
|
||||
rq.Header.Set(HeaderAuth, "BEARER "+c.AuthToken)
|
||||
}
|
||||
|
||||
rp, err := c.HttpClient.Do(rq)
|
||||
rp, err := c.HTTPClient.Do(rq)
|
||||
if err != nil || rp == nil {
|
||||
return nil, &Response{Error: NewAppError("DownloadComplianceReport", "model.client.connecting.app_error", nil, err.Error(), http.StatusBadRequest)}
|
||||
}
|
||||
@@ -4738,7 +4738,7 @@ func (c *Client4) UploadBrandImage(data []byte) (bool, *Response) {
|
||||
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
rp, err := c.HttpClient.Do(rq)
|
||||
rp, err := c.HTTPClient.Do(rq)
|
||||
if err != nil || rp == nil {
|
||||
return false, &Response{StatusCode: http.StatusForbidden, Error: NewAppError(c.GetBrandRoute()+"/image", "model.client.connecting.app_error", nil, err.Error(), http.StatusForbidden)}
|
||||
}
|
||||
@@ -4906,7 +4906,7 @@ func (c *Client4) GetOAuthAccessToken(data url.Values) (*AccessResponse, *Respon
|
||||
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
rp, err := c.HttpClient.Do(rq)
|
||||
rp, err := c.HTTPClient.Do(rq)
|
||||
if err != nil || rp == nil {
|
||||
return nil, &Response{StatusCode: http.StatusForbidden, Error: NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 403)}
|
||||
}
|
||||
@@ -5832,7 +5832,7 @@ func (c *Client4) uploadPlugin(file io.Reader, force bool) (*Manifest, *Response
|
||||
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
rp, err := c.HttpClient.Do(rq)
|
||||
rp, err := c.HTTPClient.Do(rq)
|
||||
if err != nil || rp == nil {
|
||||
return nil, BuildErrorResponse(rp, NewAppError("UploadPlugin", "model.client.connecting.app_error", nil, err.Error(), 0))
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func (o *Command) IsValid() *AppError {
|
||||
return NewAppError("Command.IsValid", "model.command.is_valid.url.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if !IsValidHttpUrl(o.URL) {
|
||||
if !IsValidHTTPUrl(o.URL) {
|
||||
return NewAppError("Command.IsValid", "model.command.is_valid.url_http.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
const (
|
||||
ConnSecurityNone = ""
|
||||
ConnSecurityPlain = "PLAIN"
|
||||
ConnSecurityTls = "TLS"
|
||||
ConnSecurityTLS = "TLS"
|
||||
ConnSecurityStarttls = "STARTTLS"
|
||||
|
||||
ImageDriverLocal = "local"
|
||||
@@ -100,8 +100,8 @@ const (
|
||||
SitenameMaxLength = 30
|
||||
|
||||
ServiceSettingsDefaultSiteUrl = "http://localhost:8065"
|
||||
ServiceSettingsDefaultTlsCertFile = ""
|
||||
ServiceSettingsDefaultTlsKeyFile = ""
|
||||
ServiceSettingsDefaultTLSCertFile = ""
|
||||
ServiceSettingsDefaultTLSKeyFile = ""
|
||||
ServiceSettingsDefaultReadTimeout = 300
|
||||
ServiceSettingsDefaultWriteTimeout = 300
|
||||
ServiceSettingsDefaultIdleTimeout = 60
|
||||
@@ -483,11 +483,11 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
|
||||
}
|
||||
|
||||
if s.TLSKeyFile == nil {
|
||||
s.TLSKeyFile = NewString(ServiceSettingsDefaultTlsKeyFile)
|
||||
s.TLSKeyFile = NewString(ServiceSettingsDefaultTLSKeyFile)
|
||||
}
|
||||
|
||||
if s.TLSCertFile == nil {
|
||||
s.TLSCertFile = NewString(ServiceSettingsDefaultTlsCertFile)
|
||||
s.TLSCertFile = NewString(ServiceSettingsDefaultTLSCertFile)
|
||||
}
|
||||
|
||||
if s.TLSMinVer == nil {
|
||||
@@ -2870,8 +2870,8 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) {
|
||||
|
||||
type GlobalRelayMessageExportSettings struct {
|
||||
CustomerType *string `access:"compliance_compliance_export"` // must be either A9 or A10, dictates SMTP server url
|
||||
SmtpUsername *string `access:"compliance_compliance_export"`
|
||||
SmtpPassword *string `access:"compliance_compliance_export"`
|
||||
SMTPUsername *string `access:"compliance_compliance_export"`
|
||||
SMTPPassword *string `access:"compliance_compliance_export"`
|
||||
EmailAddress *string `access:"compliance_compliance_export"` // the address to send messages to
|
||||
SMTPServerTimeout *int `access:"compliance_compliance_export"`
|
||||
}
|
||||
@@ -2880,11 +2880,11 @@ func (s *GlobalRelayMessageExportSettings) SetDefaults() {
|
||||
if s.CustomerType == nil {
|
||||
s.CustomerType = NewString(GlobalrelayCustomerTypeA9)
|
||||
}
|
||||
if s.SmtpUsername == nil {
|
||||
s.SmtpUsername = NewString("")
|
||||
if s.SMTPUsername == nil {
|
||||
s.SMTPUsername = NewString("")
|
||||
}
|
||||
if s.SmtpPassword == nil {
|
||||
s.SmtpPassword = NewString("")
|
||||
if s.SMTPPassword == nil {
|
||||
s.SMTPPassword = NewString("")
|
||||
}
|
||||
if s.EmailAddress == nil {
|
||||
s.EmailAddress = NewString("")
|
||||
@@ -3445,7 +3445,7 @@ func (s *FileSettings) isValid() *AppError {
|
||||
}
|
||||
|
||||
func (s *EmailSettings) isValid() *AppError {
|
||||
if !(*s.ConnectionSecurity == ConnSecurityNone || *s.ConnectionSecurity == ConnSecurityTls || *s.ConnectionSecurity == ConnSecurityStarttls || *s.ConnectionSecurity == ConnSecurityPlain) {
|
||||
if !(*s.ConnectionSecurity == ConnSecurityNone || *s.ConnectionSecurity == ConnSecurityTLS || *s.ConnectionSecurity == ConnSecurityStarttls || *s.ConnectionSecurity == ConnSecurityPlain) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.email_security.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -3481,7 +3481,7 @@ func (s *RateLimitSettings) isValid() *AppError {
|
||||
}
|
||||
|
||||
func (s *LdapSettings) isValid() *AppError {
|
||||
if !(*s.ConnectionSecurity == ConnSecurityNone || *s.ConnectionSecurity == ConnSecurityTls || *s.ConnectionSecurity == ConnSecurityStarttls) {
|
||||
if !(*s.ConnectionSecurity == ConnSecurityNone || *s.ConnectionSecurity == ConnSecurityTLS || *s.ConnectionSecurity == ConnSecurityStarttls) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.ldap_security.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -3542,11 +3542,11 @@ func (s *LdapSettings) isValid() *AppError {
|
||||
|
||||
func (s *SamlSettings) isValid() *AppError {
|
||||
if *s.Enable {
|
||||
if *s.IdpUrl == "" || !IsValidHttpUrl(*s.IdpUrl) {
|
||||
if *s.IdpUrl == "" || !IsValidHTTPUrl(*s.IdpUrl) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_url.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *s.IdpDescriptorUrl == "" || !IsValidHttpUrl(*s.IdpDescriptorUrl) {
|
||||
if *s.IdpDescriptorUrl == "" || !IsValidHTTPUrl(*s.IdpDescriptorUrl) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_descriptor_url.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -3567,7 +3567,7 @@ func (s *SamlSettings) isValid() *AppError {
|
||||
}
|
||||
|
||||
if *s.Verify {
|
||||
if *s.AssertionConsumerServiceURL == "" || !IsValidHttpUrl(*s.AssertionConsumerServiceURL) {
|
||||
if *s.AssertionConsumerServiceURL == "" || !IsValidHTTPUrl(*s.AssertionConsumerServiceURL) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.saml_assertion_consumer_service_url.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
@@ -3616,11 +3616,11 @@ func (s *SamlSettings) isValid() *AppError {
|
||||
}
|
||||
|
||||
func (s *ServiceSettings) isValid() *AppError {
|
||||
if !(*s.ConnectionSecurity == ConnSecurityNone || *s.ConnectionSecurity == ConnSecurityTls) {
|
||||
if !(*s.ConnectionSecurity == ConnSecurityNone || *s.ConnectionSecurity == ConnSecurityTLS) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.webserver_security.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *s.ConnectionSecurity == ConnSecurityTls && !*s.UseLetsEncrypt {
|
||||
if *s.ConnectionSecurity == ConnSecurityTLS && !*s.UseLetsEncrypt {
|
||||
appErr := NewAppError("Config.IsValid", "model.config.is_valid.tls_cert_file_missing.app_error", nil, "", http.StatusBadRequest)
|
||||
|
||||
if *s.TLSCertFile == "" {
|
||||
@@ -3811,9 +3811,9 @@ func (s *MessageExportSettings) isValid() *AppError {
|
||||
// validating email addresses is hard - just make sure it contains an '@' sign
|
||||
// see https://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.email_address.app_error", nil, "", http.StatusBadRequest)
|
||||
} else if s.GlobalRelaySettings.SmtpUsername == nil || *s.GlobalRelaySettings.SmtpUsername == "" {
|
||||
} else if s.GlobalRelaySettings.SMTPUsername == nil || *s.GlobalRelaySettings.SMTPUsername == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.smtp_username.app_error", nil, "", http.StatusBadRequest)
|
||||
} else if s.GlobalRelaySettings.SmtpPassword == nil || *s.GlobalRelaySettings.SmtpPassword == "" {
|
||||
} else if s.GlobalRelaySettings.SMTPPassword == nil || *s.GlobalRelaySettings.SMTPPassword == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.smtp_password.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
@@ -3914,8 +3914,8 @@ func (o *Config) Sanitize() {
|
||||
o.SqlSettings.DataSourceSearchReplicas[i] = FakeSetting
|
||||
}
|
||||
|
||||
if o.MessageExportSettings.GlobalRelaySettings.SmtpPassword != nil && *o.MessageExportSettings.GlobalRelaySettings.SmtpPassword != "" {
|
||||
*o.MessageExportSettings.GlobalRelaySettings.SmtpPassword = FakeSetting
|
||||
if o.MessageExportSettings.GlobalRelaySettings.SMTPPassword != nil && *o.MessageExportSettings.GlobalRelaySettings.SMTPPassword != "" {
|
||||
*o.MessageExportSettings.GlobalRelaySettings.SMTPPassword = FakeSetting
|
||||
}
|
||||
|
||||
if o.ServiceSettings.GfycatApiSecret != nil && *o.ServiceSettings.GfycatApiSecret != "" {
|
||||
@@ -4041,7 +4041,7 @@ func isDomainName(s string) bool {
|
||||
|
||||
func isSafeLink(link *string) bool {
|
||||
if link != nil {
|
||||
if IsValidHttpUrl(*link) {
|
||||
if IsValidHTTPUrl(*link) {
|
||||
return true
|
||||
} else if strings.HasPrefix(*link, "/") {
|
||||
return true
|
||||
|
||||
@@ -509,8 +509,8 @@ func TestMessageExportSettingsIsValidGlobalRelaySettingsInvalidCustomerType(t *t
|
||||
GlobalRelaySettings: &GlobalRelayMessageExportSettings{
|
||||
CustomerType: NewString("Invalid"),
|
||||
EmailAddress: NewString("valid@mattermost.com"),
|
||||
SmtpUsername: NewString("SomeUsername"),
|
||||
SmtpPassword: NewString("SomePassword"),
|
||||
SMTPUsername: NewString("SomeUsername"),
|
||||
SMTPPassword: NewString("SomePassword"),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -530,8 +530,8 @@ func TestMessageExportSettingsGlobalRelaySettings(t *testing.T) {
|
||||
&GlobalRelayMessageExportSettings{
|
||||
CustomerType: NewString(GlobalrelayCustomerTypeA9),
|
||||
EmailAddress: NewString("invalidEmailAddress"),
|
||||
SmtpUsername: NewString("SomeUsername"),
|
||||
SmtpPassword: NewString("SomePassword"),
|
||||
SMTPUsername: NewString("SomeUsername"),
|
||||
SMTPPassword: NewString("SomePassword"),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@@ -540,7 +540,7 @@ func TestMessageExportSettingsGlobalRelaySettings(t *testing.T) {
|
||||
&GlobalRelayMessageExportSettings{
|
||||
CustomerType: NewString(GlobalrelayCustomerTypeA10),
|
||||
EmailAddress: NewString("valid@mattermost.com"),
|
||||
SmtpPassword: NewString("SomePassword"),
|
||||
SMTPPassword: NewString("SomePassword"),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@@ -549,8 +549,8 @@ func TestMessageExportSettingsGlobalRelaySettings(t *testing.T) {
|
||||
&GlobalRelayMessageExportSettings{
|
||||
CustomerType: NewString(GlobalrelayCustomerTypeA10),
|
||||
EmailAddress: NewString("valid@mattermost.com"),
|
||||
SmtpUsername: NewString(""),
|
||||
SmtpPassword: NewString("SomePassword"),
|
||||
SMTPUsername: NewString(""),
|
||||
SMTPPassword: NewString("SomePassword"),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@@ -559,8 +559,8 @@ func TestMessageExportSettingsGlobalRelaySettings(t *testing.T) {
|
||||
&GlobalRelayMessageExportSettings{
|
||||
CustomerType: NewString(GlobalrelayCustomerTypeA10),
|
||||
EmailAddress: NewString("valid@mattermost.com"),
|
||||
SmtpUsername: NewString("SomeUsername"),
|
||||
SmtpPassword: NewString(""),
|
||||
SMTPUsername: NewString("SomeUsername"),
|
||||
SMTPPassword: NewString(""),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@@ -569,8 +569,8 @@ func TestMessageExportSettingsGlobalRelaySettings(t *testing.T) {
|
||||
&GlobalRelayMessageExportSettings{
|
||||
CustomerType: NewString(GlobalrelayCustomerTypeA9),
|
||||
EmailAddress: NewString("valid@mattermost.com"),
|
||||
SmtpUsername: NewString("SomeUsername"),
|
||||
SmtpPassword: NewString("SomePassword"),
|
||||
SMTPUsername: NewString("SomeUsername"),
|
||||
SMTPPassword: NewString("SomePassword"),
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
||||
@@ -329,15 +329,15 @@ func (m *Manifest) IsValid() error {
|
||||
return errors.New("a plugin name is needed")
|
||||
}
|
||||
|
||||
if m.HomepageURL != "" && !IsValidHttpUrl(m.HomepageURL) {
|
||||
if m.HomepageURL != "" && !IsValidHTTPUrl(m.HomepageURL) {
|
||||
return errors.New("invalid HomepageURL")
|
||||
}
|
||||
|
||||
if m.SupportURL != "" && !IsValidHttpUrl(m.SupportURL) {
|
||||
if m.SupportURL != "" && !IsValidHTTPUrl(m.SupportURL) {
|
||||
return errors.New("invalid SupportURL")
|
||||
}
|
||||
|
||||
if m.ReleaseNotesURL != "" && !IsValidHttpUrl(m.ReleaseNotesURL) {
|
||||
if m.ReleaseNotesURL != "" && !IsValidHTTPUrl(m.ReleaseNotesURL) {
|
||||
return errors.New("invalid ReleaseNotesURL")
|
||||
}
|
||||
|
||||
|
||||
@@ -66,12 +66,12 @@ func (a *OAuthApp) IsValid() *AppError {
|
||||
}
|
||||
|
||||
for _, callback := range a.CallbackUrls {
|
||||
if !IsValidHttpUrl(callback) {
|
||||
if !IsValidHTTPUrl(callback) {
|
||||
return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.callback.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
if a.Homepage == "" || len(a.Homepage) > 256 || !IsValidHttpUrl(a.Homepage) {
|
||||
if a.Homepage == "" || len(a.Homepage) > 256 || !IsValidHTTPUrl(a.Homepage) {
|
||||
return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.homepage.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func (a *OAuthApp) IsValid() *AppError {
|
||||
}
|
||||
|
||||
if a.IconURL != "" {
|
||||
if len(a.IconURL) > 512 || !IsValidHttpUrl(a.IconURL) {
|
||||
if len(a.IconURL) > 512 || !IsValidHTTPUrl(a.IconURL) {
|
||||
return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.icon_url.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ func (o *OutgoingWebhook) IsValid() *AppError {
|
||||
}
|
||||
|
||||
for _, callback := range o.CallbackURLs {
|
||||
if !IsValidHttpUrl(callback) {
|
||||
if !IsValidHTTPUrl(callback) {
|
||||
return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.url.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,8 +202,8 @@ var PermissionSysconsoleWriteEnvironmentFileStorage *Permission
|
||||
var PermissionSysconsoleReadEnvironmentImageProxy *Permission
|
||||
var PermissionSysconsoleWriteEnvironmentImageProxy *Permission
|
||||
|
||||
var PermissionSysconsoleReadEnvironmentSmtp *Permission
|
||||
var PermissionSysconsoleWriteEnvironmentSmtp *Permission
|
||||
var PermissionSysconsoleReadEnvironmentSMTP *Permission
|
||||
var PermissionSysconsoleWriteEnvironmentSMTP *Permission
|
||||
|
||||
var PermissionSysconsoleReadEnvironmentPushNotificationServer *Permission
|
||||
var PermissionSysconsoleWriteEnvironmentPushNotificationServer *Permission
|
||||
@@ -1366,13 +1366,13 @@ func initializePermissions() {
|
||||
"",
|
||||
PermissionScopeSystem,
|
||||
}
|
||||
PermissionSysconsoleReadEnvironmentSmtp = &Permission{
|
||||
PermissionSysconsoleReadEnvironmentSMTP = &Permission{
|
||||
"sysconsole_read_environment_smtp",
|
||||
"",
|
||||
"",
|
||||
PermissionScopeSystem,
|
||||
}
|
||||
PermissionSysconsoleWriteEnvironmentSmtp = &Permission{
|
||||
PermissionSysconsoleWriteEnvironmentSMTP = &Permission{
|
||||
"sysconsole_write_environment_smtp",
|
||||
"",
|
||||
"",
|
||||
@@ -1912,7 +1912,7 @@ func initializePermissions() {
|
||||
PermissionSysconsoleReadEnvironmentElasticsearch,
|
||||
PermissionSysconsoleReadEnvironmentFileStorage,
|
||||
PermissionSysconsoleReadEnvironmentImageProxy,
|
||||
PermissionSysconsoleReadEnvironmentSmtp,
|
||||
PermissionSysconsoleReadEnvironmentSMTP,
|
||||
PermissionSysconsoleReadEnvironmentPushNotificationServer,
|
||||
PermissionSysconsoleReadEnvironmentHighAvailability,
|
||||
PermissionSysconsoleReadEnvironmentRateLimiting,
|
||||
@@ -1969,7 +1969,7 @@ func initializePermissions() {
|
||||
PermissionSysconsoleWriteEnvironmentElasticsearch,
|
||||
PermissionSysconsoleWriteEnvironmentFileStorage,
|
||||
PermissionSysconsoleWriteEnvironmentImageProxy,
|
||||
PermissionSysconsoleWriteEnvironmentSmtp,
|
||||
PermissionSysconsoleWriteEnvironmentSMTP,
|
||||
PermissionSysconsoleWriteEnvironmentPushNotificationServer,
|
||||
PermissionSysconsoleWriteEnvironmentHighAvailability,
|
||||
PermissionSysconsoleWriteEnvironmentRateLimiting,
|
||||
|
||||
@@ -89,7 +89,7 @@ func init() {
|
||||
PermissionSysconsoleWriteEnvironmentFileStorage.Id: {
|
||||
PermissionTestS3,
|
||||
},
|
||||
PermissionSysconsoleWriteEnvironmentSmtp.Id: {
|
||||
PermissionSysconsoleWriteEnvironmentSMTP.Id: {
|
||||
PermissionTestEmail,
|
||||
},
|
||||
PermissionSysconsoleReadReportingServerLogs.Id: {
|
||||
@@ -216,7 +216,7 @@ func init() {
|
||||
PermissionSysconsoleReadEnvironmentElasticsearch.Id,
|
||||
PermissionSysconsoleReadEnvironmentFileStorage.Id,
|
||||
PermissionSysconsoleReadEnvironmentImageProxy.Id,
|
||||
PermissionSysconsoleReadEnvironmentSmtp.Id,
|
||||
PermissionSysconsoleReadEnvironmentSMTP.Id,
|
||||
PermissionSysconsoleReadEnvironmentPushNotificationServer.Id,
|
||||
PermissionSysconsoleReadEnvironmentHighAvailability.Id,
|
||||
PermissionSysconsoleReadEnvironmentRateLimiting.Id,
|
||||
@@ -274,7 +274,7 @@ func init() {
|
||||
PermissionSysconsoleReadEnvironmentElasticsearch.Id,
|
||||
PermissionSysconsoleReadEnvironmentFileStorage.Id,
|
||||
PermissionSysconsoleReadEnvironmentImageProxy.Id,
|
||||
PermissionSysconsoleReadEnvironmentSmtp.Id,
|
||||
PermissionSysconsoleReadEnvironmentSMTP.Id,
|
||||
PermissionSysconsoleReadEnvironmentPushNotificationServer.Id,
|
||||
PermissionSysconsoleReadEnvironmentHighAvailability.Id,
|
||||
PermissionSysconsoleReadEnvironmentRateLimiting.Id,
|
||||
@@ -287,7 +287,7 @@ func init() {
|
||||
PermissionSysconsoleWriteEnvironmentElasticsearch.Id,
|
||||
PermissionSysconsoleWriteEnvironmentFileStorage.Id,
|
||||
PermissionSysconsoleWriteEnvironmentImageProxy.Id,
|
||||
PermissionSysconsoleWriteEnvironmentSmtp.Id,
|
||||
PermissionSysconsoleWriteEnvironmentSMTP.Id,
|
||||
PermissionSysconsoleWriteEnvironmentPushNotificationServer.Id,
|
||||
PermissionSysconsoleWriteEnvironmentHighAvailability.Id,
|
||||
PermissionSysconsoleWriteEnvironmentRateLimiting.Id,
|
||||
|
||||
@@ -488,7 +488,7 @@ func ClearMentionTags(post string) string {
|
||||
return post
|
||||
}
|
||||
|
||||
func IsValidHttpUrl(rawUrl string) bool {
|
||||
func IsValidHTTPUrl(rawUrl string) bool {
|
||||
if strings.Index(rawUrl, "http://") != 0 && strings.Index(rawUrl, "https://") != 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -855,7 +855,7 @@ func TestSanitizeUnicode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsValidHttpUrl(t *testing.T) {
|
||||
func TestIsValidHTTPUrl(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
@@ -940,7 +940,7 @@ func TestIsValidHttpUrl(t *testing.T) {
|
||||
}()
|
||||
|
||||
t.Parallel()
|
||||
require.Equal(t, testCase.Expected, IsValidHttpUrl(testCase.Value))
|
||||
require.Equal(t, testCase.Expected, IsValidHTTPUrl(testCase.Value))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user