Commit 7b3be6c7 authored by Elias Nahum's avatar Elias Nahum

PLT-7: Refactoring manuatesting & utils to use translations (chunk 5)

- Add spanish translations
- Skip tests
parent e880835f
......@@ -797,7 +797,7 @@
},
{
"id": "api.post.update_post.permissions_details.app_error",
"translation": "Already delted id={{.PostId}}"
"translation": "Already deleted id={{.PostId}}"
},
{
"id": "api.post_get_post_by_id.get.app_error",
......@@ -1639,12 +1639,140 @@
"id": "api.webhook.regen_outgoing_token.permissions.app_error",
"translation": "Inappropriate permissions to regenerate outcoming webhook token"
},
{
"id": "manaultesting.get_channel_id.no_found.debug",
"translation": "Could not find channel: %v, %v possibilites searched"
},
{
"id": "manaultesting.get_channel_id.unable.debug",
"translation": "Unable to get channels"
},
{
"id": "manaultesting.manual_test.create.info",
"translation": "Creating user and team"
},
{
"id": "manaultesting.manual_test.parse.app_error",
"translation": "Unable to parse URL"
},
{
"id": "manaultesting.manual_test.setup.info",
"translation": "Setting up for manual test..."
},
{
"id": "manaultesting.manual_test.uid.debug",
"translation": "No uid in url"
},
{
"id": "manaultesting.test_autolink.info",
"translation": "Manual Auto Link Test"
},
{
"id": "manaultesting.test_autolink.unable.app_error",
"translation": "Unable to get channels"
},
{
"id": "mattermost.current_version",
"translation": "Current version is %v (%v/%v/%v)"
},
{
"id": "utils.config.load_config.decoding.panic",
"translation": "Error decoding config file={{.Filename}}, err={{.Error}}"
},
{
"id": "utils.config.load_config.getting.panic",
"translation": "Error getting config info file={{.Filename}}, err={{.Error}}"
},
{
"id": "utils.config.load_config.opening.panic",
"translation": "Error opening config file={{.Filename}}, err={{.Error}}"
},
{
"id": "utils.config.load_config.validating.panic",
"translation": "Error validating config file={{.Filename}}, err={{.Error}}"
},
{
"id": "utils.config.save_config.saving.app_error",
"translation": "An error occurred while saving the file to {{.Filename}}"
},
{
"id": "utils.i18n.loaded",
"translation": "Loaded system translations for '%v' from '%v'"
},
{
"id": "utils.iru.with_evict",
"translation": "Must provide a positive size"
},
{
"id": "utils.license.load_license.invalid.warn",
"translation": "No valid enterprise license found"
},
{
"id": "utils.license.load_license.open_find.warn",
"translation": "Unable to open/find license file"
},
{
"id": "utils.license.remove_license.unable.error",
"translation": "Unable to remove license file, err=%v"
},
{
"id": "utils.license.validate_license.decode.error",
"translation": "Encountered error decoding license, err=%v"
},
{
"id": "utils.license.validate_license.invalid.error",
"translation": "Invalid signature, err=%v"
},
{
"id": "utils.license.validate_license.not_long.error",
"translation": "Signed license not long enough"
},
{
"id": "utils.license.validate_license.signing.error",
"translation": "Encountered error signing license, err=%v"
},
{
"id": "utils.mail.connect_smtp.open.app_error",
"translation": "Failed to open connection"
},
{
"id": "utils.mail.connect_smtp.open_tls.app_error",
"translation": "Failed to open TLS connection"
},
{
"id": "utils.mail.new_client.auth.app_error",
"translation": "Failed to authenticate on SMTP server"
},
{
"id": "utils.mail.new_client.open.error",
"translation": "Failed to open a connection to SMTP server %v"
},
{
"id": "utils.mail.send_mail.close.app_error",
"translation": "Failed to close connection to SMTP server"
},
{
"id": "utils.mail.send_mail.from_address.app_error",
"translation": "Failed to add from email address"
},
{
"id": "utils.mail.send_mail.msg.app_error",
"translation": "Failed to write email message"
},
{
"id": "utils.mail.send_mail.msg_data.app_error",
"translation": "Failed to add email messsage data"
},
{
"id": "utils.mail.send_mail.sending.debug",
"translation": "sending mail to %v with subject of '%v'"
},
{
"id": "utils.mail.send_mail.to_address.app_error",
"translation": "Failed to add to email address"
},
{
"id": "utils.mail.test.configured.error",
"translation": "SMTP server settings do not appear to be configured properly err=%v details=%v"
}
]
\ No newline at end of file
......@@ -797,7 +797,7 @@
},
{
"id": "api.post.update_post.permissions_details.app_error",
"translation": "Already delted id={{.PostId}}"
"translation": "Ya fué elminado el id={{.PostId}}"
},
{
"id": "api.post_get_post_by_id.get.app_error",
......@@ -1639,12 +1639,140 @@
"id": "api.webhook.regen_outgoing_token.permissions.app_error",
"translation": "Permisos inapropiados para regenerar un token para el Webhook saliente"
},
{
"id": "manaultesting.get_channel_id.no_found.debug",
"translation": "No pudimos encontrar el canal: %v, búsqueda realizada con estas posibilidades %v"
},
{
"id": "manaultesting.get_channel_id.unable.debug",
"translation": "No se pudo obtener los canales"
},
{
"id": "manaultesting.manual_test.create.info",
"translation": "Creando usuario y equipo"
},
{
"id": "manaultesting.manual_test.parse.app_error",
"translation": "No se pudo analizar el URL"
},
{
"id": "manaultesting.manual_test.setup.info",
"translation": "Configurando para pruebas manuales..."
},
{
"id": "manaultesting.manual_test.uid.debug",
"translation": "No hay un uid en el url"
},
{
"id": "manaultesting.test_autolink.info",
"translation": "Prueba Manual de Enlaces Automáticos"
},
{
"id": "manaultesting.test_autolink.unable.app_error",
"translation": "No se pudo obtener los canales"
},
{
"id": "mattermost.current_version",
"translation": "La versión actual es %v (%v/%v/%v)"
},
{
"id": "utils.config.load_config.decoding.panic",
"translation": "Error decifrando la configuración del archivo={{.Filename}}, err={{.Error}}"
},
{
"id": "utils.config.load_config.getting.panic",
"translation": "Error obteniendo la iformación de configuración del archivo={{.Filename}}, err={{.Error}}"
},
{
"id": "utils.config.load_config.opening.panic",
"translation": "Error abriendo la configuración del archivo={{.Filename}}, err={{.Error}}"
},
{
"id": "utils.config.load_config.validating.panic",
"translation": "Error validando la configuración del archivo={{.Filename}}, err={{.Error}}"
},
{
"id": "utils.config.save_config.saving.app_error",
"translation": "Ocurrió un error mientras se guardaba el archivo en {{.Filename}}"
},
{
"id": "utils.i18n.loaded",
"translation": "Cargada traducciones del sistema para '%v' desde '%v'"
},
{
"id": "utils.iru.with_evict",
"translation": "Debe proporcionar un tamaño positivo"
},
{
"id": "utils.license.load_license.invalid.warn",
"translation": "No se encontró una licencia enterprise válida"
},
{
"id": "utils.license.load_license.open_find.warn",
"translation": "No pudimos encontrar/abrir el achivo de licencia"
},
{
"id": "utils.license.remove_license.unable.error",
"translation": "No se pudo remover el archivo de la licencia, err=%v"
},
{
"id": "utils.license.validate_license.decode.error",
"translation": "Encontramos un error decodificando la licencia, err=%v"
},
{
"id": "utils.license.validate_license.invalid.error",
"translation": "Firma inválida, err=%v"
},
{
"id": "utils.license.validate_license.not_long.error",
"translation": "La licencia firmada no es suficientemente larga"
},
{
"id": "utils.license.validate_license.signing.error",
"translation": "Encontramos un error al firmar la licencia, err=%v"
},
{
"id": "utils.mail.connect_smtp.open.app_error",
"translation": "Falla al abrir conexión"
},
{
"id": "utils.mail.connect_smtp.open_tls.app_error",
"translation": "Falla al abrir una conexión TLS"
},
{
"id": "utils.mail.new_client.auth.app_error",
"translation": "Falla autenticando contra el servidor SMTP"
},
{
"id": "utils.mail.new_client.open.error",
"translation": "Falla al abrir la conexión al servidor SMTP %v"
},
{
"id": "utils.mail.send_mail.close.app_error",
"translation": "Falla al cerrar la conexión al servidor SMTP"
},
{
"id": "utils.mail.send_mail.from_address.app_error",
"translation": "Falla al agregar el correo electrónico desde"
},
{
"id": "utils.mail.send_mail.msg.app_error",
"translation": "Falla al escribir el mensaje del correo electrónico"
},
{
"id": "utils.mail.send_mail.msg_data.app_error",
"translation": "Falla al agregar la data al mensaje del correo electrónico"
},
{
"id": "utils.mail.send_mail.sending.debug",
"translation": "enviano correo electrónico a %v con el asunto '%v'"
},
{
"id": "utils.mail.send_mail.to_address.app_error",
"translation": "Falla al agregar el correo electrónico para"
},
{
"id": "utils.mail.test.configured.error",
"translation": "El servidor SMTP parece no estar configurado apropiadamente err=%v details=%v"
}
]
\ No newline at end of file
......@@ -32,12 +32,12 @@ func InitManualTesting() {
func manualTest(c *api.Context, w http.ResponseWriter, r *http.Request) {
// Let the world know
l4g.Info("Setting up for manual test...")
l4g.Info(utils.T("manaultesting.manual_test.setup.info"))
// URL Parameters
params, err := url.ParseQuery(r.URL.RawQuery)
if err != nil {
c.Err = model.NewAppError("/manual", "Unable to parse URL", "")
c.Err = model.NewLocAppError("/manual", "manaultesting.manual_test.parse.app_error", nil, "")
return
}
......@@ -49,7 +49,7 @@ func manualTest(c *api.Context, w http.ResponseWriter, r *http.Request) {
hash := hasher.Sum32()
rand.Seed(int64(hash))
} else {
l4g.Debug("No uid in url")
l4g.Debug(utils.T("manaultesting.manual_test.uid.debug"))
}
// Create a client for tests to use
......@@ -61,7 +61,7 @@ func manualTest(c *api.Context, w http.ResponseWriter, r *http.Request) {
var teamID string
var userID string
if ok1 && ok2 {
l4g.Info("Creating user and team")
l4g.Info(utils.T("manaultesting.manual_test.create.info"))
// Create team for testing
team := &model.Team{
DisplayName: teamDisplayName[0],
......@@ -153,7 +153,7 @@ func getChannelID(channelname string, teamid string, userid string) (id string,
// Grab all the channels
result := <-api.Srv.Store.Channel().GetChannels(teamid, userid)
if result.Err != nil {
l4g.Debug("Unable to get channels")
l4g.Debug(utils.T("manaultesting.get_channel_id.unable.debug"))
return "", false
}
......@@ -164,6 +164,6 @@ func getChannelID(channelname string, teamid string, userid string) (id string,
return channel.Id, true
}
}
l4g.Debug("Could not find channel: " + channelname + ", " + strconv.Itoa(len(data.Channels)) + " possibilites searched")
l4g.Debug(utils.T("manaultesting.get_channel_id.no_found.debug"), channelname, strconv.Itoa(len(data.Channels)))
return "", false
}
......@@ -6,6 +6,7 @@ package manualtesting
import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
)
const LINK_POST_TEXT = `
......@@ -20,10 +21,10 @@ https://medium.com/@slackhq/11-useful-tips-for-getting-the-most-of-slack-5dfb3d1
`
func testAutoLink(env TestEnvironment) *model.AppError {
l4g.Info("Manual Auto Link Test")
l4g.Info(utils.T("manaultesting.test_autolink.info"))
channelID, err := getChannelID(model.DEFAULT_CHANNEL, env.CreatedTeamId, env.CreatedUserId)
if err != true {
return model.NewAppError("/manualtest", "Unable to get channels", "")
return model.NewLocAppError("/manualtest", "manaultesting.test_autolink.unable.app_error", nil, "")
}
post := &model.Post{
......
......@@ -118,12 +118,14 @@ func GetLogFileLocation(fileLocation string) string {
func SaveConfig(fileName string, config *model.Config) *model.AppError {
b, err := json.MarshalIndent(config, "", " ")
if err != nil {
return model.NewAppError("SaveConfig", "An error occurred while saving the file to "+fileName, err.Error())
return model.NewLocAppError("SaveConfig", "utils.config.save_config.saving.app_error",
map[string]interface{}{"Filename": fileName}, err.Error())
}
err = ioutil.WriteFile(fileName, b, 0644)
if err != nil {
return model.NewAppError("SaveConfig", "An error occurred while saving the file to "+fileName, err.Error())
return model.NewLocAppError("SaveConfig", "utils.config.save_config.saving.app_error",
map[string]interface{}{"Filename": fileName}, err.Error())
}
return nil
......@@ -138,18 +140,21 @@ func LoadConfig(fileName string) {
file, err := os.Open(fileName)
if err != nil {
panic("Error opening config file=" + fileName + ", err=" + err.Error())
panic(T("utils.config.load_config.opening.panic",
map[string]interface{}{"Filename": fileName, "Error": err.Error()}))
}
decoder := json.NewDecoder(file)
config := model.Config{}
err = decoder.Decode(&config)
if err != nil {
panic("Error decoding config file=" + fileName + ", err=" + err.Error())
panic(T("utils.config.load_config.decoding.panic",
map[string]interface{}{"Filename": fileName, "Error": err.Error()}))
}
if info, err := file.Stat(); err != nil {
panic("Error getting config info file=" + fileName + ", err=" + err.Error())
panic(T("utils.config.load_config.getting.panic",
map[string]interface{}{"Filename": fileName, "Error": err.Error()}))
} else {
CfgLastModified = info.ModTime().Unix()
CfgFileName = fileName
......@@ -158,7 +163,8 @@ func LoadConfig(fileName string) {
config.SetDefaults()
if err := config.IsValid(); err != nil {
panic("Error validating config file=" + fileName + ", err=" + err.Message)
panic(T("utils.config.load_config.validating.panic",
map[string]interface{}{"Filename": fileName, "Error": err.Message}))
}
configureLog(&config.LogSettings)
......
......@@ -9,4 +9,5 @@ import (
func TestConfig(t *testing.T) {
LoadConfig("config.json")
InitTranslations()
}
......@@ -44,7 +44,7 @@ NxpC+5KFhU+xSeeklNqwCgnlOyZ7qSTxmdJHb+60SwuYnnGIYzLJhY4LYDr4J+KR
func LoadLicense() {
file, err := os.Open(LicenseLocation())
if err != nil {
l4g.Warn("Unable to open/find license file")
l4g.Warn(T("utils.license.load_license.open_find.warn"))
return
}
defer file.Close()
......@@ -58,7 +58,7 @@ func LoadLicense() {
return
}
l4g.Warn("No valid enterprise license found")
l4g.Warn(T("utils.license.load_license.invalid.warn"))
}
func SetLicense(license *model.License) bool {
......@@ -84,7 +84,7 @@ func RemoveLicense() bool {
ClientLicense = getClientLicense(License)
if err := os.Remove(LicenseLocation()); err != nil {
l4g.Error("Unable to remove license file, err=%v", err.Error())
l4g.Error(T("utils.license.remove_license.unable.error"), err.Error())
return false
}
......@@ -96,12 +96,12 @@ func ValidateLicense(signed []byte) (bool, string) {
_, err := base64.StdEncoding.Decode(decoded, signed)
if err != nil {
l4g.Error("Encountered error decoding license, err=%v", err.Error())
l4g.Error(T("utils.license.validate_license.decode.error"), err.Error())
return false, ""
}
if len(decoded) <= 256 {
l4g.Error("Signed license not long enough")
l4g.Error(T("utils.license.validate_license.not_long.error"))
return false, ""
}
......@@ -117,7 +117,7 @@ func ValidateLicense(signed []byte) (bool, string) {
public, err := x509.ParsePKIXPublicKey(block.Bytes)
if err != nil {
l4g.Error("Encountered error signing license, err=%v", err.Error())
l4g.Error(T("utils.license.validate_license.signing.error"), err.Error())
return false, ""
}
......@@ -129,7 +129,7 @@ func ValidateLicense(signed []byte) (bool, string) {
err = rsa.VerifyPKCS1v15(rsaPublic, crypto.SHA512, d, signature)
if err != nil {
l4g.Error("Invalid signature, err=%v", err.Error())
l4g.Error(T("utils.license.validate_license.invalid.error"), err.Error())
return false, ""
}
......
......@@ -38,7 +38,7 @@ func NewLru(size int) *Cache {
func NewLruWithEvict(size int, onEvicted func(key interface{}, value interface{})) (*Cache, error) {
if size <= 0 {
return nil, errors.New("Must provide a positive size")
return nil, errors.New(T("utils.iru.with_evict"))
}
c := &Cache{
size: size,
......
......@@ -34,12 +34,12 @@ func connectToSMTPServer(config *model.Config) (net.Conn, *model.AppError) {
conn, err = tls.Dial("tcp", config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort, tlsconfig)
if err != nil {
return nil, model.NewAppError("SendMail", "Failed to open TLS connection", err.Error())
return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error())
}
} else {
conn, err = net.Dial("tcp", config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
if err != nil {
return nil, model.NewAppError("SendMail", "Failed to open connection", err.Error())
return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.open.app_error", nil, err.Error())
}
}
......@@ -49,15 +49,15 @@ func connectToSMTPServer(config *model.Config) (net.Conn, *model.AppError) {
func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.AppError) {
c, err := smtp.NewClient(conn, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
if err != nil {
l4g.Error("Failed to open a connection to SMTP server %v", err)
return nil, model.NewAppError("SendMail", "Failed to open TLS connection", err.Error())
l4g.Error(T("utils.mail.new_client.open.error"), err)
return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error())
}
// GO does not support plain auth over a non encrypted connection.
// so if not tls then no auth
auth := smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
if config.EmailSettings.ConnectionSecurity == model.CONN_SECURITY_TLS {
if err = c.Auth(auth); err != nil {
return nil, model.NewAppError("SendMail", "Failed to authenticate on SMTP server", err.Error())
return nil, model.NewLocAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error())
}
} else if config.EmailSettings.ConnectionSecurity == model.CONN_SECURITY_STARTTLS {
tlsconfig := &tls.Config{
......@@ -66,7 +66,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap
}
c.StartTLS(tlsconfig)
if err = c.Auth(auth); err != nil {
return nil, model.NewAppError("SendMail", "Failed to authenticate on SMTP server", err.Error())
return nil, model.NewLocAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error())
}
}
return c, nil
......@@ -79,14 +79,14 @@ func TestConnection(config *model.Config) {
conn, err1 := connectToSMTPServer(config)
if err1 != nil {
l4g.Error("SMTP server settings do not appear to be configured properly err=%v details=%v", err1.Message, err1.DetailedError)
l4g.Error(T("utils.mail.test.configured.error"), err1.Message, err1.DetailedError)
return
}
defer conn.Close()
c, err2 := newSMTPClient(conn, config)
if err2 != nil {
l4g.Error("SMTP connection settings do not appear to be configured properly err=%v details=%v", err2.Message, err2.DetailedError)
l4g.Error(T("utils.mail.test.configured.error"), err2.Message, err2.DetailedError)
return
}
defer c.Quit()
......@@ -102,7 +102,7 @@ func SendMailUsingConfig(to, subject, body string, config *model.Config) *model.
return nil
}
l4g.Debug("sending mail to " + to + " with subject of '" + subject + "'")
l4g.Debug(T("utils.mail.send_mail.sending.debug"), to, subject)
fromMail := mail.Address{config.EmailSettings.FeedbackName, config.EmailSettings.FeedbackEmail}
toMail := mail.Address{"", to}
......@@ -136,26 +136,26 @@ func SendMailUsingConfig(to, subject, body string, config *model.Config) *model.
defer c.Close()
if err := c.Mail(fromMail.Address); err != nil {
return model.NewAppError("SendMail", "Failed to add from email address", err.Error())
return model.NewLocAppError("SendMail", "utils.mail.send_mail.from_address.app_error", nil, err.Error())
}
if err := c.Rcpt(toMail.Address); err != nil {
return model.NewAppError("SendMail", "Failed to add to email address", err.Error())
return model.NewLocAppError("SendMail", "utils.mail.send_mail.to_address.app_error", nil, err.Error())
}
w, err := c.Data()
if err != nil {
return model.NewAppError("SendMail", "Failed to add email messsage data", err.Error())
return model.NewLocAppError("SendMail", "utils.mail.send_mail.msg_data.app_error", nil, err.Error())
}
_, err = w.Write([]byte(message))
if err != nil {
return model.NewAppError("SendMail", "Failed to write email message", err.Error())
return model.NewLocAppError("SendMail", "utils.mail.send_mail.msg.app_error", nil, err.Error())
}
err = w.Close()
if err != nil {
return model.NewAppError("SendMail", "Failed to close connection to SMTP server", err.Error())
return model.NewLocAppError("SendMail", "utils.mail.send_mail.close.app_error", nil, err.Error())
}
return nil
......
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