Commit 531cec93 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

feat: emit warning if nonexisting lang is requested forkeyshare server emails

parent 211671ba
......@@ -41,6 +41,8 @@ func (conf EmailConfiguration) TranslateString(strings map[string]string, lang s
if ok {
return s
}
server.Logger.WithField("lang", lang).
Warn("email string translation requested for unknown language, falling back to default")
return strings[conf.DefaultLanguage]
}
......@@ -49,6 +51,8 @@ func (conf EmailConfiguration) translateTemplate(templates map[string]*template.
if ok {
return t
}
server.Logger.WithField("lang", lang).
Warn("email template translation requested for unknown language, falling back to default")
return templates[conf.DefaultLanguage]
}
......
......@@ -17,8 +17,11 @@ func TestServerRegistrationWithEmail(t *testing.T) {
200, nil,
)
// If somehow the IRMA app gains support for a language earlier than the keyshare server,
// rejecting the registration would be too severe. So the registration is accepted and the
// server falls back to its default language.
test.HTTPPost(t, nil, "http://localhost:8080/irma_keyshare_server/api/v1/client/register",
`{"pin":"testpin","email":"test@test.com","language":"dne"}`, nil,
`{"pin":"testpin","email":"test@test.com","language":"nonexistinglanguage"}`, nil,
200, nil,
)
......@@ -28,7 +31,7 @@ func TestServerRegistrationWithEmail(t *testing.T) {
)
test.HTTPPost(t, nil, "http://localhost:8080/irma_keyshare_server/api/v1/client/register",
`{"pin":"testpin","language":"dne"}`, nil,
`{"pin":"testpin","language":"nonexistinglanguage"}`, nil,
200, nil,
)
}
......@@ -61,7 +61,7 @@ func TestServerHandleRegister(t *testing.T) {
200, nil,
)
test.HTTPPost(t, nil, "http://localhost:8080/irma_keyshare_server/api/v1/client/register",
`{"pin":"testpin","email":"test@test.com","language":"dne"}`, nil,
`{"pin":"testpin","email":"test@test.com","language":"nonexistinglanguage"}`, nil,
200, nil,
)
test.HTTPPost(t, nil, "http://localhost:8080/irma_keyshare_server/api/v1/client/register",
......@@ -69,7 +69,7 @@ func TestServerHandleRegister(t *testing.T) {
200, nil,
)
test.HTTPPost(t, nil, "http://localhost:8080/irma_keyshare_server/api/v1/client/register",
`{"pin":"testpin","language":"dne"}`, nil,
`{"pin":"testpin","language":"nonexistinglanguage"}`, nil,
200, nil,
)
}
......
......@@ -32,11 +32,11 @@ func TestServerLoginEmail(t *testing.T) {
myirmaServer, httpServer := StartMyIrmaServer(t, db, "localhost:1025")
defer StopMyIrmaServer(t, myirmaServer, httpServer)
test.HTTPPost(t, nil, "http://localhost:8080/login/email", `{"email": "dne", "language": "en"}`, nil, 403, nil)
test.HTTPPost(t, nil, "http://localhost:8080/login/email", `{"email": "nonexistinglanguage", "language": "en"}`, nil, 403, nil)
test.HTTPPost(t, nil, "http://localhost:8080/login/email", `{"email": "test@test.com", "language":"en"}`, nil, 204, nil)
test.HTTPPost(t, nil, "http://localhost:8080/login/email", `{"email": "test@test.com", "language":"dne"}`, nil, 204, nil)
test.HTTPPost(t, nil, "http://localhost:8080/login/email", `{"email": "test@test.com", "language":"nonexistinglanguage"}`, nil, 204, nil)
client := test.NewHTTPClient()
......
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