[MM-37772] Idiomatic naming (URL, URI, API) (#18128)

* s/Url/URL/g & s/Uri/URI/g

* s/Api/API/g
Этот коммит содержится в:
Ben Schumacher
2021-08-16 19:46:44 +02:00
коммит произвёл GitHub
родитель a7f5512ff3
Коммит 757dc96461
155 изменённых файлов: 1680 добавлений и 1681 удалений

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

@@ -35,7 +35,6 @@ type AccessResponse struct {
// IsValid validates the AccessData and returns an error if it isn't configured
// correctly.
func (ad *AccessData) IsValid() *AppError {
if ad.ClientId == "" || len(ad.ClientId) > 26 {
return NewAppError("AccessData.IsValid", "model.access.is_valid.client_id.app_error", nil, "", http.StatusBadRequest)
}
@@ -52,7 +51,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)
}

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

@@ -28,7 +28,7 @@ type AuthData struct {
type AuthorizeRequest struct {
ResponseType string `json:"response_type"`
ClientId string `json:"client_id"`
RedirectUri string `json:"redirect_uri"`
RedirectURI string `json:"redirect_uri"`
Scope string `json:"scope"`
State string `json:"state"`
}
@@ -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)
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@@ -15,13 +15,13 @@ import (
// https://github.com/mattermost/mattermost-plugin-starter-template/issues/115
func TestClient4TrimTrailingSlash(t *testing.T) {
slashes := []int{0, 1, 5}
baseUrl := "https://foo.com:1234"
baseURL := "https://foo.com:1234"
for _, s := range slashes {
testUrl := baseUrl + strings.Repeat("/", s)
client := NewAPIv4Client(testUrl)
assert.Equal(t, baseUrl, client.Url)
assert.Equal(t, baseUrl+ApiUrlSuffix, client.ApiUrl)
testURL := baseURL + strings.Repeat("/", s)
client := NewAPIv4Client(testURL)
assert.Equal(t, baseURL, client.URL)
assert.Equal(t, baseURL+APIURLSuffix, client.APIURL)
}
}

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

@@ -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)
}

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

@@ -99,7 +99,7 @@ const (
SitenameMaxLength = 30
ServiceSettingsDefaultSiteUrl = "http://localhost:8065"
ServiceSettingsDefaultSiteURL = "http://localhost:8065"
ServiceSettingsDefaultTLSCertFile = ""
ServiceSettingsDefaultTLSKeyFile = ""
ServiceSettingsDefaultReadTimeout = 300
@@ -108,8 +108,8 @@ const (
ServiceSettingsDefaultMaxLoginAttempts = 10
ServiceSettingsDefaultAllowCorsFrom = ""
ServiceSettingsDefaultListenAndAddress = ":8065"
ServiceSettingsDefaultGfycatApiKey = "2_KtH_W5"
ServiceSettingsDefaultGfycatApiSecret = "3wLVZPiswc3DnaiaFoLkDvB4X0IV6CpMkj4tf2inJRsBY6-FnkT08zGmppWFgeof"
ServiceSettingsDefaultGfycatAPIKey = "2_KtH_W5"
ServiceSettingsDefaultGfycatAPISecret = "3wLVZPiswc3DnaiaFoLkDvB4X0IV6CpMkj4tf2inJRsBY6-FnkT08zGmppWFgeof"
TeamSettingsDefaultSiteName = "Mattermost"
TeamSettingsDefaultMaxUsersPerTeam = 50
@@ -179,12 +179,12 @@ const (
AnnouncementSettingsDefaultBannerColor = "#f2a93b"
AnnouncementSettingsDefaultBannerTextColor = "#333333"
AnnouncementSettingsDefaultNoticesJsonUrl = "https://notices.mattermost.com/"
AnnouncementSettingsDefaultNoticesJsonURL = "https://notices.mattermost.com/"
AnnouncementSettingsDefaultNoticesFetchFrequencySeconds = 3600
TeamSettingsDefaultTeamText = "default"
ElasticsearchSettingsDefaultConnectionUrl = "http://localhost:9200"
ElasticsearchSettingsDefaultConnectionURL = "http://localhost:9200"
ElasticsearchSettingsDefaultUsername = "elastic"
ElasticsearchSettingsDefaultPassword = "changeme"
ElasticsearchSettingsDefaultPostIndexReplicas = 1
@@ -211,8 +211,8 @@ const (
PluginSettingsDefaultDirectory = "./plugins"
PluginSettingsDefaultClientDirectory = "./client/plugins"
PluginSettingsDefaultEnableMarketplace = true
PluginSettingsDefaultMarketplaceUrl = "https://api.integrations.mattermost.com"
PluginSettingsOldMarketplaceUrl = "https://marketplace.integrations.mattermost.com"
PluginSettingsDefaultMarketplaceURL = "https://api.integrations.mattermost.com"
PluginSettingsOldMarketplaceURL = "https://marketplace.integrations.mattermost.com"
ComplianceExportTypeCsv = "csv"
ComplianceExportTypeActiance = "actiance"
@@ -230,15 +230,15 @@ const (
GoogleSettingsDefaultScope = "profile email"
GoogleSettingsDefaultAuthEndpoint = "https://accounts.google.com/o/oauth2/v2/auth"
GoogleSettingsDefaultTokenEndpoint = "https://www.googleapis.com/oauth2/v4/token"
GoogleSettingsDefaultUserApiEndpoint = "https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses,nicknames,metadata"
GoogleSettingsDefaultUserAPIEndpoint = "https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses,nicknames,metadata"
Office365SettingsDefaultScope = "User.Read"
Office365SettingsDefaultAuthEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
Office365SettingsDefaultTokenEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/token"
Office365SettingsDefaultUserApiEndpoint = "https://graph.microsoft.com/v1.0/me"
Office365SettingsDefaultUserAPIEndpoint = "https://graph.microsoft.com/v1.0/me"
CloudSettingsDefaultCwsUrl = "https://customers.mattermost.com"
CloudSettingsDefaultCwsApiUrl = "https://portal.internal.prod.cloud.mattermost.com"
CloudSettingsDefaultCwsURL = "https://customers.mattermost.com"
CloudSettingsDefaultCwsAPIURL = "https://portal.internal.prod.cloud.mattermost.com"
OpenidSettingsDefaultScope = "profile openid email"
LocalModeSocketPath = "/var/tmp/mattermost_local.socket"
@@ -329,8 +329,8 @@ type ServiceSettings struct {
WebsocketPort *int `access:"write_restrictable,cloud_restrictable"` // telemetry: none
WebserverMode *string `access:"environment_web_server,write_restrictable,cloud_restrictable"`
EnableGifPicker *bool `access:"integrations_gif"`
GfycatApiKey *string `access:"integrations_gif"`
GfycatApiSecret *string `access:"integrations_gif"`
GfycatAPIKey *string `access:"integrations_gif"`
GfycatAPISecret *string `access:"integrations_gif"`
EnableCustomEmoji *bool `access:"site_emoji"`
EnableEmojiPicker *bool `access:"site_emoji"`
DEPRECATED_DO_NOT_USE_RestrictCustomEmojiCreation *string `json:"RestrictCustomEmojiCreation" mapstructure:"RestrictCustomEmojiCreation"` // Deprecated: do not use
@@ -392,7 +392,7 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
if s.SiteURL == nil {
if s.EnableDeveloper != nil && *s.EnableDeveloper {
s.SiteURL = NewString(ServiceSettingsDefaultSiteUrl)
s.SiteURL = NewString(ServiceSettingsDefaultSiteURL)
} else {
s.SiteURL = NewString("")
}
@@ -683,12 +683,12 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
s.EnableGifPicker = NewBool(true)
}
if s.GfycatApiKey == nil || *s.GfycatApiKey == "" {
s.GfycatApiKey = NewString(ServiceSettingsDefaultGfycatApiKey)
if s.GfycatAPIKey == nil || *s.GfycatAPIKey == "" {
s.GfycatAPIKey = NewString(ServiceSettingsDefaultGfycatAPIKey)
}
if s.GfycatApiSecret == nil || *s.GfycatApiSecret == "" {
s.GfycatApiSecret = NewString(ServiceSettingsDefaultGfycatApiSecret)
if s.GfycatAPISecret == nil || *s.GfycatAPISecret == "" {
s.GfycatAPISecret = NewString(ServiceSettingsDefaultGfycatAPISecret)
}
if s.DEPRECATED_DO_NOT_USE_RestrictCustomEmojiCreation == nil {
@@ -1015,13 +1015,13 @@ type SSOSettings struct {
Scope *string `access:"authentication_openid"` // telemetry: none
AuthEndpoint *string `access:"authentication_openid"` // telemetry: none
TokenEndpoint *string `access:"authentication_openid"` // telemetry: none
UserApiEndpoint *string `access:"authentication_openid"` // telemetry: none
UserAPIEndpoint *string `access:"authentication_openid"` // telemetry: none
DiscoveryEndpoint *string `access:"authentication_openid"` // telemetry: none
ButtonText *string `access:"authentication_openid"` // telemetry: none
ButtonColor *string `access:"authentication_openid"` // telemetry: none
}
func (s *SSOSettings) setDefaults(scope, authEndpoint, tokenEndpoint, userApiEndpoint, buttonColor string) {
func (s *SSOSettings) setDefaults(scope, authEndpoint, tokenEndpoint, userAPIEndpoint, buttonColor string) {
if s.Enable == nil {
s.Enable = NewBool(false)
}
@@ -1050,8 +1050,8 @@ func (s *SSOSettings) setDefaults(scope, authEndpoint, tokenEndpoint, userApiEnd
s.TokenEndpoint = NewString(tokenEndpoint)
}
if s.UserApiEndpoint == nil {
s.UserApiEndpoint = NewString(userApiEndpoint)
if s.UserAPIEndpoint == nil {
s.UserAPIEndpoint = NewString(userAPIEndpoint)
}
if s.ButtonText == nil {
@@ -1070,7 +1070,7 @@ type Office365Settings struct {
Scope *string `access:"authentication_openid"`
AuthEndpoint *string `access:"authentication_openid"` // telemetry: none
TokenEndpoint *string `access:"authentication_openid"` // telemetry: none
UserApiEndpoint *string `access:"authentication_openid"` // telemetry: none
UserAPIEndpoint *string `access:"authentication_openid"` // telemetry: none
DiscoveryEndpoint *string `access:"authentication_openid"` // telemetry: none
DirectoryId *string `access:"authentication_openid"` // telemetry: none
}
@@ -1104,8 +1104,8 @@ func (s *Office365Settings) setDefaults() {
s.TokenEndpoint = NewString(Office365SettingsDefaultTokenEndpoint)
}
if s.UserApiEndpoint == nil {
s.UserApiEndpoint = NewString(Office365SettingsDefaultUserApiEndpoint)
if s.UserAPIEndpoint == nil {
s.UserAPIEndpoint = NewString(Office365SettingsDefaultUserAPIEndpoint)
}
if s.DirectoryId == nil {
@@ -1122,7 +1122,7 @@ func (s *Office365Settings) SSOSettings() *SSOSettings {
ssoSettings.DiscoveryEndpoint = s.DiscoveryEndpoint
ssoSettings.AuthEndpoint = s.AuthEndpoint
ssoSettings.TokenEndpoint = s.TokenEndpoint
ssoSettings.UserApiEndpoint = s.UserApiEndpoint
ssoSettings.UserAPIEndpoint = s.UserAPIEndpoint
return &ssoSettings
}
@@ -1882,7 +1882,7 @@ func (s *AnnouncementSettings) SetDefaults() {
s.UserNoticesEnabled = NewBool(true)
}
if s.NoticesURL == nil {
s.NoticesURL = NewString(AnnouncementSettingsDefaultNoticesJsonUrl)
s.NoticesURL = NewString(AnnouncementSettingsDefaultNoticesJsonURL)
}
if s.NoticesSkipCache == nil {
s.NoticesSkipCache = NewBool(false)
@@ -2369,9 +2369,9 @@ type SamlSettings struct {
Encrypt *bool `access:"authentication_saml"`
SignRequest *bool `access:"authentication_saml"`
IdpUrl *string `access:"authentication_saml"` // telemetry: none
IdpDescriptorUrl *string `access:"authentication_saml"` // telemetry: none
IdpMetadataUrl *string `access:"authentication_saml"` // telemetry: none
IdpURL *string `access:"authentication_saml"` // telemetry: none
IdpDescriptorURL *string `access:"authentication_saml"` // telemetry: none
IdpMetadataURL *string `access:"authentication_saml"` // telemetry: none
ServiceProviderIdentifier *string `access:"authentication_saml"` // telemetry: none
AssertionConsumerServiceURL *string `access:"authentication_saml"` // telemetry: none
@@ -2446,24 +2446,24 @@ func (s *SamlSettings) SetDefaults() {
s.CanonicalAlgorithm = NewString(SamlSettingsDefaultCanonicalAlgorithm)
}
if s.IdpUrl == nil {
s.IdpUrl = NewString("")
if s.IdpURL == nil {
s.IdpURL = NewString("")
}
if s.IdpDescriptorUrl == nil {
s.IdpDescriptorUrl = NewString("")
if s.IdpDescriptorURL == nil {
s.IdpDescriptorURL = NewString("")
}
if s.ServiceProviderIdentifier == nil {
if s.IdpDescriptorUrl != nil {
s.ServiceProviderIdentifier = NewString(*s.IdpDescriptorUrl)
if s.IdpDescriptorURL != nil {
s.ServiceProviderIdentifier = NewString(*s.IdpDescriptorURL)
} else {
s.ServiceProviderIdentifier = NewString("")
}
}
if s.IdpMetadataUrl == nil {
s.IdpMetadataUrl = NewString("")
if s.IdpMetadataURL == nil {
s.IdpMetadataURL = NewString("")
}
if s.IdpCertificateFile == nil {
@@ -2571,7 +2571,7 @@ func (s *NativeAppSettings) SetDefaults() {
}
type ElasticsearchSettings struct {
ConnectionUrl *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
ConnectionURL *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
Username *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
Password *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
EnableIndexing *bool `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
@@ -2595,8 +2595,8 @@ type ElasticsearchSettings struct {
}
func (s *ElasticsearchSettings) SetDefaults() {
if s.ConnectionUrl == nil {
s.ConnectionUrl = NewString(ElasticsearchSettingsDefaultConnectionUrl)
if s.ConnectionURL == nil {
s.ConnectionURL = NewString(ElasticsearchSettingsDefaultConnectionURL)
}
if s.Username == nil {
@@ -2761,16 +2761,16 @@ func (s *JobSettings) SetDefaults() {
}
type CloudSettings struct {
CWSUrl *string `access:"write_restrictable"`
CWSAPIUrl *string `access:"write_restrictable"`
CWSURL *string `access:"write_restrictable"`
CWSAPIURL *string `access:"write_restrictable"`
}
func (s *CloudSettings) SetDefaults() {
if s.CWSUrl == nil {
s.CWSUrl = NewString(CloudSettingsDefaultCwsUrl)
if s.CWSURL == nil {
s.CWSURL = NewString(CloudSettingsDefaultCwsURL)
}
if s.CWSAPIUrl == nil {
s.CWSAPIUrl = NewString(CloudSettingsDefaultCwsApiUrl)
if s.CWSAPIURL == nil {
s.CWSAPIURL = NewString(CloudSettingsDefaultCwsAPIURL)
}
}
@@ -2781,7 +2781,7 @@ type PluginState struct {
type PluginSettings struct {
Enable *bool `access:"plugins,write_restrictable"`
EnableUploads *bool `access:"plugins,write_restrictable,cloud_restrictable"`
AllowInsecureDownloadUrl *bool `access:"plugins,write_restrictable,cloud_restrictable"`
AllowInsecureDownloadURL *bool `access:"plugins,write_restrictable,cloud_restrictable"`
EnableHealthCheck *bool `access:"plugins,write_restrictable,cloud_restrictable"`
Directory *string `access:"plugins,write_restrictable,cloud_restrictable"` // telemetry: none
ClientDirectory *string `access:"plugins,write_restrictable,cloud_restrictable"` // telemetry: none
@@ -2791,9 +2791,9 @@ type PluginSettings struct {
EnableRemoteMarketplace *bool `access:"plugins,write_restrictable,cloud_restrictable"`
AutomaticPrepackagedPlugins *bool `access:"plugins,write_restrictable,cloud_restrictable"`
RequirePluginSignature *bool `access:"plugins,write_restrictable,cloud_restrictable"`
MarketplaceUrl *string `access:"plugins,write_restrictable,cloud_restrictable"`
MarketplaceURL *string `access:"plugins,write_restrictable,cloud_restrictable"`
SignaturePublicKeyFiles []string `access:"plugins,write_restrictable,cloud_restrictable"`
ChimeraOAuthProxyUrl *string `access:"plugins,write_restrictable,cloud_restrictable"`
ChimeraOAuthProxyURL *string `access:"plugins,write_restrictable,cloud_restrictable"`
}
func (s *PluginSettings) SetDefaults(ls LogSettings) {
@@ -2805,8 +2805,8 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) {
s.EnableUploads = NewBool(false)
}
if s.AllowInsecureDownloadUrl == nil {
s.AllowInsecureDownloadUrl = NewBool(false)
if s.AllowInsecureDownloadURL == nil {
s.AllowInsecureDownloadURL = NewBool(false)
}
if s.EnableHealthCheck == nil {
@@ -2856,8 +2856,8 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) {
s.AutomaticPrepackagedPlugins = NewBool(true)
}
if s.MarketplaceUrl == nil || *s.MarketplaceUrl == "" || *s.MarketplaceUrl == PluginSettingsOldMarketplaceUrl {
s.MarketplaceUrl = NewString(PluginSettingsDefaultMarketplaceUrl)
if s.MarketplaceURL == nil || *s.MarketplaceURL == "" || *s.MarketplaceURL == PluginSettingsOldMarketplaceURL {
s.MarketplaceURL = NewString(PluginSettingsDefaultMarketplaceURL)
}
if s.RequirePluginSignature == nil {
@@ -2868,8 +2868,8 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) {
s.SignaturePublicKeyFiles = []string{}
}
if s.ChimeraOAuthProxyUrl == nil {
s.ChimeraOAuthProxyUrl = NewString("")
if s.ChimeraOAuthProxyURL == nil {
s.ChimeraOAuthProxyURL = NewString("")
}
}
@@ -2943,14 +2943,14 @@ func (s *MessageExportSettings) SetDefaults() {
}
type DisplaySettings struct {
CustomUrlSchemes []string `access:"site_customization"`
CustomURLSchemes []string `access:"site_customization"`
ExperimentalTimezone *bool `access:"experimental_features"`
}
func (s *DisplaySettings) SetDefaults() {
if s.CustomUrlSchemes == nil {
customUrlSchemes := []string{}
s.CustomUrlSchemes = customUrlSchemes
if s.CustomURLSchemes == nil {
customURLSchemes := []string{}
s.CustomURLSchemes = customURLSchemes
}
if s.ExperimentalTimezone == nil {
@@ -3245,7 +3245,7 @@ func (o *Config) SetDefaults() {
o.Office365Settings.setDefaults()
o.Office365Settings.setDefaults()
o.GitLabSettings.setDefaults("", "", "", "", "")
o.GoogleSettings.setDefaults(GoogleSettingsDefaultScope, GoogleSettingsDefaultAuthEndpoint, GoogleSettingsDefaultTokenEndpoint, GoogleSettingsDefaultUserApiEndpoint, "")
o.GoogleSettings.setDefaults(GoogleSettingsDefaultScope, GoogleSettingsDefaultAuthEndpoint, GoogleSettingsDefaultTokenEndpoint, GoogleSettingsDefaultUserAPIEndpoint, "")
o.OpenIdSettings.setDefaults(OpenidSettingsDefaultScope, "", "", "", "#145DBF")
o.ServiceSettings.SetDefaults(isUpdate)
o.PasswordSettings.SetDefaults()
@@ -3547,11 +3547,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)
}
@@ -3572,7 +3572,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)
}
}
@@ -3708,7 +3708,7 @@ func (s *ServiceSettings) isValid() *AppError {
func (s *ElasticsearchSettings) isValid() *AppError {
if *s.EnableIndexing {
if *s.ConnectionUrl == "" {
if *s.ConnectionURL == "" {
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.connection_url.app_error", nil, "", http.StatusBadRequest)
}
}
@@ -3827,10 +3827,10 @@ func (s *MessageExportSettings) isValid() *AppError {
}
func (s *DisplaySettings) isValid() *AppError {
if len(s.CustomUrlSchemes) != 0 {
if len(s.CustomURLSchemes) != 0 {
validProtocolPattern := regexp.MustCompile(`(?i)^\s*[A-Za-z][A-Za-z0-9.+-]*\s*$`)
for _, scheme := range s.CustomUrlSchemes {
for _, scheme := range s.CustomURLSchemes {
if !validProtocolPattern.MatchString(scheme) {
return NewAppError(
"Config.IsValid",
@@ -3923,8 +3923,8 @@ func (o *Config) Sanitize() {
*o.MessageExportSettings.GlobalRelaySettings.SMTPPassword = FakeSetting
}
if o.ServiceSettings.GfycatApiSecret != nil && *o.ServiceSettings.GfycatApiSecret != "" {
*o.ServiceSettings.GfycatApiSecret = FakeSetting
if o.ServiceSettings.GfycatAPISecret != nil && *o.ServiceSettings.GfycatAPISecret != "" {
*o.ServiceSettings.GfycatAPISecret = FakeSetting
}
*o.ServiceSettings.SplitKey = FakeSetting
@@ -4046,7 +4046,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

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

@@ -73,7 +73,7 @@ func TestConfigEnableDeveloper(t *testing.T) {
EnableDeveloper *bool
ExpectedSiteURL string
}{
{"enable developer is true", NewBool(true), ServiceSettingsDefaultSiteUrl},
{"enable developer is true", NewBool(true), ServiceSettingsDefaultSiteURL},
{"enable developer is false", NewBool(false), ""},
{"enable developer is nil", nil, ""},
}
@@ -144,8 +144,8 @@ func TestConfigIsValidDefaultAlgorithms(t *testing.T) {
*c1.SamlSettings.Verify = false
*c1.SamlSettings.Encrypt = false
*c1.SamlSettings.IdpUrl = "http://test.url.com"
*c1.SamlSettings.IdpDescriptorUrl = "http://test.url.com"
*c1.SamlSettings.IdpURL = "http://test.url.com"
*c1.SamlSettings.IdpDescriptorURL = "http://test.url.com"
*c1.SamlSettings.IdpCertificateFile = "certificatefile"
*c1.SamlSettings.ServiceProviderIdentifier = "http://test.url.com"
*c1.SamlSettings.EmailAttribute = "Email"
@@ -161,8 +161,8 @@ func TestConfigServiceProviderDefault(t *testing.T) {
Enable: NewBool(true),
Verify: NewBool(false),
Encrypt: NewBool(false),
IdpUrl: NewString("http://test.url.com"),
IdpDescriptorUrl: NewString("http://test2.url.com"),
IdpURL: NewString("http://test.url.com"),
IdpDescriptorURL: NewString("http://test2.url.com"),
IdpCertificateFile: NewString("certificatefile"),
EmailAttribute: NewString("Email"),
UsernameAttribute: NewString("Username"),
@@ -170,7 +170,7 @@ func TestConfigServiceProviderDefault(t *testing.T) {
}
c1.SetDefaults()
assert.Equal(t, *c1.SamlSettings.ServiceProviderIdentifier, *c1.SamlSettings.IdpDescriptorUrl)
assert.Equal(t, *c1.SamlSettings.ServiceProviderIdentifier, *c1.SamlSettings.IdpDescriptorURL)
err := c1.SamlSettings.isValid()
require.Nil(t, err)
@@ -184,9 +184,9 @@ func TestConfigIsValidFakeAlgorithm(t *testing.T) {
*c1.SamlSettings.Verify = false
*c1.SamlSettings.Encrypt = false
*c1.SamlSettings.IdpUrl = "http://test.url.com"
*c1.SamlSettings.IdpDescriptorUrl = "http://test.url.com"
*c1.SamlSettings.IdpMetadataUrl = "http://test.url.com"
*c1.SamlSettings.IdpURL = "http://test.url.com"
*c1.SamlSettings.IdpDescriptorURL = "http://test.url.com"
*c1.SamlSettings.IdpMetadataURL = "http://test.url.com"
*c1.SamlSettings.IdpCertificateFile = "certificatefile"
*c1.SamlSettings.ServiceProviderIdentifier = "http://test.url.com"
*c1.SamlSettings.EmailAttribute = "Email"
@@ -688,7 +688,7 @@ func TestMessageExportSetDefaultsExportDisabledExportFromTimestampNonZero(t *tes
require.Equal(t, 10000, *mes.BatchSize)
}
func TestDisplaySettingsIsValidCustomUrlSchemes(t *testing.T) {
func TestDisplaySettingsIsValidCustomURLSchemes(t *testing.T) {
tests := []struct {
name string
value []string
@@ -760,12 +760,12 @@ func TestDisplaySettingsIsValidCustomUrlSchemes(t *testing.T) {
ds := &DisplaySettings{}
ds.SetDefaults()
ds.CustomUrlSchemes = test.value
ds.CustomURLSchemes = test.value
if err := ds.isValid(); err != nil && test.valid {
t.Error("Expected CustomUrlSchemes to be valid but got error:", err)
t.Error("Expected CustomURLSchemes to be valid but got error:", err)
} else if err == nil && !test.valid {
t.Error("Expected CustomUrlSchemes to be invalid but got no error")
t.Error("Expected CustomURLSchemes to be invalid but got no error")
}
})
}
@@ -1368,29 +1368,29 @@ func TestConfigMarketplaceDefaults(t *testing.T) {
c.SetDefaults()
require.True(t, *c.PluginSettings.EnableMarketplace)
require.Equal(t, PluginSettingsDefaultMarketplaceUrl, *c.PluginSettings.MarketplaceUrl)
require.Equal(t, PluginSettingsDefaultMarketplaceURL, *c.PluginSettings.MarketplaceURL)
})
t.Run("old marketplace url", func(t *testing.T) {
c := Config{}
c.SetDefaults()
*c.PluginSettings.MarketplaceUrl = PluginSettingsOldMarketplaceUrl
*c.PluginSettings.MarketplaceURL = PluginSettingsOldMarketplaceURL
c.SetDefaults()
require.True(t, *c.PluginSettings.EnableMarketplace)
require.Equal(t, PluginSettingsDefaultMarketplaceUrl, *c.PluginSettings.MarketplaceUrl)
require.Equal(t, PluginSettingsDefaultMarketplaceURL, *c.PluginSettings.MarketplaceURL)
})
t.Run("custom marketplace url", func(t *testing.T) {
c := Config{}
c.SetDefaults()
*c.PluginSettings.MarketplaceUrl = "https://marketplace.example.com"
*c.PluginSettings.MarketplaceURL = "https://marketplace.example.com"
c.SetDefaults()
require.True(t, *c.PluginSettings.EnableMarketplace)
require.Equal(t, "https://marketplace.example.com", *c.PluginSettings.MarketplaceUrl)
require.Equal(t, "https://marketplace.example.com", *c.PluginSettings.MarketplaceURL)
})
}

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

@@ -321,15 +321,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)
}
}

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

@@ -108,7 +108,7 @@ var PermissionCreateComplianceExportJob *Permission
var PermissionReadComplianceExportJob *Permission
var PermissionReadAudits *Permission
var PermissionTestElasticsearch *Permission
var PermissionTestSiteUrl *Permission
var PermissionTestSiteURL *Permission
var PermissionTestS3 *Permission
var PermissionReloadConfig *Permission
var PermissionInvalidateCaches *Permission
@@ -909,7 +909,7 @@ func initializePermissions() {
PermissionScopeSystem,
}
PermissionTestSiteUrl = &Permission{
PermissionTestSiteURL = &Permission{
"test_site_url",
"",
"",
@@ -2048,7 +2048,7 @@ func initializePermissions() {
PermissionCreateComplianceExportJob,
PermissionReadComplianceExportJob,
PermissionReadAudits,
PermissionTestSiteUrl,
PermissionTestSiteURL,
PermissionTestElasticsearch,
PermissionTestS3,
PermissionReloadConfig,

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

@@ -62,7 +62,7 @@ const (
PostPropsAddedUserId = "addedUserId"
PostPropsDeleteBy = "deleteBy"
PostPropsOverrideIconUrl = "override_icon_url"
PostPropsOverrideIconURL = "override_icon_url"
PostPropsOverrideIconEmoji = "override_icon_emoji"
PostPropsMentionHighlightDisabled = "mentionHighlightDisabled"

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

@@ -64,7 +64,7 @@ type PushNotification struct {
SenderId string `json:"sender_id,omitempty"`
SenderName string `json:"sender_name,omitempty"`
OverrideUsername string `json:"override_username,omitempty"`
OverrideIconUrl string `json:"override_icon_url,omitempty"`
OverrideIconURL string `json:"override_icon_url,omitempty"`
FromWebhook string `json:"from_webhook,omitempty"`
Version string `json:"version,omitempty"`
IsIdLoaded bool `json:"is_id_loaded"`

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

@@ -73,7 +73,7 @@ func init() {
PermissionReadElasticsearchPostAggregationJob,
},
PermissionSysconsoleWriteEnvironmentWebServer.Id: {
PermissionTestSiteUrl,
PermissionTestSiteURL,
PermissionReloadConfig,
PermissionInvalidateCaches,
},

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

@@ -31,8 +31,8 @@ type SamlCertificateStatus struct {
}
type SamlMetadataResponse struct {
IdpDescriptorUrl string `json:"idp_descriptor_url"`
IdpUrl string `json:"idp_url"`
IdpDescriptorURL string `json:"idp_descriptor_url"`
IdpURL string `json:"idp_url"`
IdpPublicCertificate string `json:"idp_public_certificate"`
}

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

@@ -487,12 +487,12 @@ func ClearMentionTags(post string) string {
return post
}
func IsValidHTTPUrl(rawUrl string) bool {
if strings.Index(rawUrl, "http://") != 0 && strings.Index(rawUrl, "https://") != 0 {
func IsValidHTTPURL(rawURL string) bool {
if strings.Index(rawURL, "http://") != 0 && strings.Index(rawURL, "https://") != 0 {
return false
}
if u, err := url.ParseRequestURI(rawUrl); err != nil || u.Scheme == "" || u.Host == "" {
if u, err := url.ParseRequestURI(rawURL); err != nil || u.Scheme == "" || u.Host == "" {
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))
})
}
}

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

@@ -37,9 +37,9 @@ const avgReadMsgSizeBytes = 1024
// A client must read from PingTimeoutChannel, EventChannel and ResponseChannel to prevent
// deadlocks from occurring in the program.
type WebSocketClient struct {
Url string // The location of the server like "ws://localhost:8065"
ApiUrl string // The API location of the server like "ws://localhost:8065/api/v3"
ConnectUrl string // The WebSocket URL to connect to like "ws://localhost:8065/api/v3/path/to/websocket"
URL string // The location of the server like "ws://localhost:8065"
APIURL string // The API location of the server like "ws://localhost:8065/api/v3"
ConnectURL string // The WebSocket URL to connect to like "ws://localhost:8065/api/v3/path/to/websocket"
Conn *websocket.Conn // The WebSocket connection
AuthToken string // The token used to open the WebSocket connection
Sequence int64 // The ever-incrementing sequence attached to each WebSocket action
@@ -66,15 +66,15 @@ func NewWebSocketClient(url, authToken string) (*WebSocketClient, error) {
// NewWebSocketClientWithDialer constructs a new WebSocket client with convenience
// methods for talking to the server using a custom dialer.
func NewWebSocketClientWithDialer(dialer *websocket.Dialer, url, authToken string) (*WebSocketClient, error) {
conn, _, err := dialer.Dial(url+ApiUrlSuffix+"/websocket", nil)
conn, _, err := dialer.Dial(url+APIURLSuffix+"/websocket", nil)
if err != nil {
return nil, NewAppError("NewWebSocketClient", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
}
client := &WebSocketClient{
Url: url,
ApiUrl: url + ApiUrlSuffix,
ConnectUrl: url + ApiUrlSuffix + "/websocket",
URL: url,
APIURL: url + APIURLSuffix,
ConnectURL: url + APIURLSuffix + "/websocket",
Conn: conn,
AuthToken: authToken,
Sequence: 1,
@@ -107,17 +107,17 @@ func NewWebSocketClient4WithDialer(dialer *websocket.Dialer, url, authToken stri
return NewWebSocketClientWithDialer(dialer, url, authToken)
}
// Connect creates a websocket connection with the given ConnectUrl.
// Connect creates a websocket connection with the given ConnectURL.
// This is racy and error-prone should not be used. Use any of the New* functions to create a websocket.
func (wsc *WebSocketClient) Connect() *AppError {
return wsc.ConnectWithDialer(websocket.DefaultDialer)
}
// ConnectWithDialer creates a websocket connection with the given ConnectUrl using the dialer.
// ConnectWithDialer creates a websocket connection with the given ConnectURL using the dialer.
// This is racy and error-prone and should not be used. Use any of the New* functions to create a websocket.
func (wsc *WebSocketClient) ConnectWithDialer(dialer *websocket.Dialer) *AppError {
var err error
wsc.Conn, _, err = dialer.Dial(wsc.ConnectUrl, nil)
wsc.Conn, _, err = dialer.Dial(wsc.ConnectURL, nil)
if err != nil {
return NewAppError("Connect", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
}