From af09848dd8349306f1321682efd1b8ed085e69c4 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Wed, 18 Aug 2021 17:24:48 +0200 Subject: [PATCH] Fix tests (use translation keys) --- auth/assets/templates/signup.html.tpl | 32 ++++++++++---------- auth/auth.go | 3 ++ auth/handlers/handle_change-password_test.go | 2 +- auth/handlers/handle_login_test.go | 6 ++-- auth/handlers/handle_mfa_test.go | 4 +-- auth/handlers/handle_password-reset_test.go | 8 ++--- auth/handlers/handle_profile_test.go | 14 ++++----- auth/handlers/handle_security_test.go | 2 +- auth/handlers/handle_signup.go | 8 ++--- auth/handlers/handle_signup_test.go | 4 +-- pkg/errors/http_test.go | 5 +-- pkg/locale/locale.go | 6 ++-- store/tests/compose_records_test.go | 2 +- tests/automation/trigger_test.go | 6 ++-- tests/automation/workflow_test.go | 8 ++--- tests/compose/chart_test.go | 6 ++-- tests/compose/module_test.go | 6 ++-- tests/compose/namespace_test.go | 6 ++-- tests/compose/page_test.go | 6 ++-- tests/compose/record_test.go | 8 ++--- tests/system/application_test.go | 12 ++++---- tests/system/reminder_test.go | 8 ++--- tests/system/role_test.go | 10 +++--- tests/system/template_test.go | 8 ++--- tests/system/user_test.go | 6 ++-- 25 files changed, 96 insertions(+), 90 deletions(-) diff --git a/auth/assets/templates/signup.html.tpl b/auth/assets/templates/signup.html.tpl index 837dcad80..e97b4573d 100644 --- a/auth/assets/templates/signup.html.tpl +++ b/auth/assets/templates/signup.html.tpl @@ -1,6 +1,6 @@ {{ template "inc_header.html.tpl" . }}
-

{{ tr "singup.template.title" }}

+

{{ tr "signup.template.title" }}

+ aria-label="{{ tr "signup.template.form.email.aria-label" }}">
+ aria-label="{{ tr "signup.template.form.password.aria-label" }}">
+ aria-label="{{ tr "signup.template.form.name.aria-label" }}">
+ aria-label="{{ tr "signup.template.form.nickname.aria-label" }}">
+ >{{ tr "signup.template.form.button.sign-up" }}
-
{{ tr "singup.template.form.link.alternative" }} - {{ tr "singup.template.form.link.login" }} +
{{ tr "signup.template.form.link.alternative" }} + {{ tr "signup.template.form.link.login" }}
{{ template "inc_footer.html.tpl" . }} diff --git a/auth/auth.go b/auth/auth.go index 412790fbf..0d8c76ab1 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -166,6 +166,9 @@ func New(ctx context.Context, log *zap.Logger, s store.Storer, opt options.AuthO "version": func() string { return version.Version }, "buildtime": func() string { return version.BuildTime }, "links": handlers.GetLinks, + + // temp, will be replaced + "tr": func(key string, pp ...string) string { return key }, }) useEmbedded = len(opt.AssetsPath) == 0 diff --git a/auth/handlers/handle_change-password_test.go b/auth/handlers/handle_change-password_test.go index 1a0770dbc..54e9f4151 100644 --- a/auth/handlers/handle_change-password_test.go +++ b/auth/handlers/handle_change-password_test.go @@ -63,7 +63,7 @@ func Test_changePasswordProc(t *testing.T) { { name: "successful password change", payload: map[string]string(nil), - alerts: []request.Alert{{Type: "primary", Text: "Password successfully changed.", Html: ""}}, + alerts: []request.Alert{{Type: "primary", Text: "change-password.alerts.text", Html: ""}}, link: GetLinks().Profile, fn: func(_ *settings.Settings) { authService = &authServiceMocked{ diff --git a/auth/handlers/handle_login_test.go b/auth/handlers/handle_login_test.go index 56d8e30bb..6d83fb125 100644 --- a/auth/handlers/handle_login_test.go +++ b/auth/handlers/handle_login_test.go @@ -75,7 +75,7 @@ func Test_loginProc(t *testing.T) { { name: "successful login", payload: map[string]string(nil), - alerts: []request.Alert{{Type: "primary", Text: "You are now logged-in", Html: ""}}, + alerts: []request.Alert{{Type: "primary", Text: "login.alerts.logged-in", Html: ""}}, link: GetLinks().Profile, fn: func(_ *settings.Settings) { authService = &authServiceMocked{ @@ -93,7 +93,7 @@ func Test_loginProc(t *testing.T) { { name: "internal login is not enabled", payload: map[string]string(nil), - alerts: []request.Alert{{Type: "danger", Text: "Local accounts disabled", Html: ""}}, + alerts: []request.Alert{{Type: "danger", Text: "login.alert.local-disabled", Html: ""}}, link: GetLinks().Profile, fn: func(_ *settings.Settings) { authService = &authServiceMocked{ @@ -138,7 +138,7 @@ func Test_loginProc(t *testing.T) { }, { name: "credentials linked to invalid user", - payload: map[string]string{"email": "mockuser@example.tld", "error": "credentials {credentials.kind} linked to disabled or deleted user {user}"}, + payload: map[string]string{"email": "mockuser@example.tld", "error": "credentials {{credentials.kind}} linked to disabled or deleted user {{user}}"}, alerts: []request.Alert(nil), link: GetLinks().Login, fn: func(*settings.Settings) { diff --git a/auth/handlers/handle_mfa_test.go b/auth/handlers/handle_mfa_test.go index 19e52a76b..2eeb123bf 100644 --- a/auth/handlers/handle_mfa_test.go +++ b/auth/handlers/handle_mfa_test.go @@ -31,7 +31,7 @@ func Test_mfaProc(t *testing.T) { { name: "Email: successful login", payload: map[string]string(nil), - alerts: []request.Alert{{Type: "primary", Text: "Email OTP valid"}}, + alerts: []request.Alert{{Type: "primary", Text: "mfa.handle.email-resent"}}, link: GetLinks().Profile, fn: func(_ *settings.Settings) { req.Form.Set("action", "verifyEmailOtp") @@ -47,7 +47,7 @@ func Test_mfaProc(t *testing.T) { { name: "TOTP: successful login", payload: map[string]string(nil), - alerts: []request.Alert{{Type: "primary", Text: "TOTP valid"}}, + alerts: []request.Alert{{Type: "primary", Text: "mfa.handle.topt-valid"}}, link: GetLinks().Mfa, fn: func(_ *settings.Settings) { req.Form.Set("action", "verifyTotp") diff --git a/auth/handlers/handle_password-reset_test.go b/auth/handlers/handle_password-reset_test.go index ddea1ca2f..a03d66dda 100644 --- a/auth/handlers/handle_password-reset_test.go +++ b/auth/handlers/handle_password-reset_test.go @@ -80,7 +80,7 @@ func Test_resetPasswordForm(t *testing.T) { { name: "invalid password reset token", payload: map[string]string(nil), - alerts: []request.Alert{{Type: "warning", Text: "Invalid or expired password reset token, please repeat password reset request."}}, + alerts: []request.Alert{{Type: "warning", Text: "password_reset_requested.alert.inv-exp-passw-token"}}, link: GetLinks().RequestPasswordReset, template: TmplResetPassword, fn: func(_ *settings.Settings) { @@ -153,7 +153,7 @@ func Test_requestPasswordReset(t *testing.T) { { name: "request reset disabled", payload: map[string]string(nil), - alerts: []request.Alert{{Type: "danger", Text: "Password reset disabled"}}, + alerts: []request.Alert{{Type: "danger", Text: "password_reset_requested.alert.pass-reset-disabled"}}, link: GetLinks().Login, fn: func(_ *settings.Settings) { authService = &authServiceMocked{ @@ -207,7 +207,7 @@ func Test_requestPasswordProc(t *testing.T) { { name: "reset password success", payload: map[string]string(nil), - alerts: []request.Alert{{Type: "primary", Text: "Password successfully reset.", Html: ""}}, + alerts: []request.Alert{{Type: "primary", Text: "password_reset_requested.alert.pass-reset-success", Html: ""}}, link: GetLinks().Profile, fn: func(_ *settings.Settings) { authService = &authServiceMocked{ @@ -220,7 +220,7 @@ func Test_requestPasswordProc(t *testing.T) { { name: "reset password disabled", payload: map[string]string(nil), - alerts: []request.Alert{{Type: "danger", Text: "Password reset disabled", Html: ""}}, + alerts: []request.Alert{{Type: "danger", Text: "password_reset_requested.alert.pass-reset-disabled", Html: ""}}, link: GetLinks().Login, fn: func(_ *settings.Settings) { authService = &authServiceMocked{ diff --git a/auth/handlers/handle_profile_test.go b/auth/handlers/handle_profile_test.go index 5a2805004..548d3bd71 100644 --- a/auth/handlers/handle_profile_test.go +++ b/auth/handlers/handle_profile_test.go @@ -71,7 +71,7 @@ func Test_profileFormProc(t *testing.T) { { name: "success", err: "", - alerts: []request.Alert{{Type: "primary", Text: "Profile successfully updated.", Html: ""}}, + alerts: []request.Alert{{Type: "primary", Text: "profile.alerts.profile-updated", Html: ""}}, link: GetLinks().Profile, payload: map[string]string(nil), fn: func(_ *settings.Settings) { @@ -91,7 +91,7 @@ func Test_profileFormProc(t *testing.T) { { name: "proc invalid ID", err: "", - alerts: []request.Alert{{Type: "danger", Text: "Could not update profile due to input errors", Html: ""}}, + alerts: []request.Alert{{Type: "danger", Text: "profile.alerts.profile-update-fail", Html: ""}}, link: GetLinks().Profile, payload: map[string]string{"email": "mockuser@example.tld", "error": "invalid ID", "handle": "handle", "name": "name"}, fn: func(_ *settings.Settings) { @@ -108,7 +108,7 @@ func Test_profileFormProc(t *testing.T) { { name: "proc invalid handle", err: "", - alerts: []request.Alert{{Type: "danger", Text: "Could not update profile due to input errors", Html: ""}}, + alerts: []request.Alert{{Type: "danger", Text: "profile.alerts.profile-update-fail", Html: ""}}, link: GetLinks().Profile, payload: map[string]string{"email": "mockuser@example.tld", "error": "invalid handle", "handle": "handle", "name": "name"}, fn: func(_ *settings.Settings) { @@ -125,7 +125,7 @@ func Test_profileFormProc(t *testing.T) { { name: "proc invalid email", err: "", - alerts: []request.Alert{{Type: "danger", Text: "Could not update profile due to input errors", Html: ""}}, + alerts: []request.Alert{{Type: "danger", Text: "profile.alerts.profile-update-fail", Html: ""}}, link: GetLinks().Profile, payload: map[string]string{"email": "mockuser@example.tld", "error": "invalid email", "handle": "handle", "name": "name"}, fn: func(_ *settings.Settings) { @@ -142,7 +142,7 @@ func Test_profileFormProc(t *testing.T) { { name: "proc handle not unique", err: "", - alerts: []request.Alert{{Type: "danger", Text: "Could not update profile due to input errors", Html: ""}}, + alerts: []request.Alert{{Type: "danger", Text: "profile.alerts.profile-update-fail", Html: ""}}, link: GetLinks().Profile, payload: map[string]string{"email": "mockuser@example.tld", "error": "handle not unique", "handle": "handle", "name": "name"}, fn: func(_ *settings.Settings) { @@ -157,9 +157,9 @@ func Test_profileFormProc(t *testing.T) { }, }, { - name: "not allowed to update this user", + name: "user.errors.notAllowedToUpdate", err: "", - alerts: []request.Alert{{Type: "danger", Text: "Could not update profile due to input errors", Html: ""}}, + alerts: []request.Alert{{Type: "danger", Text: "profile.alerts.profile-update-fail", Html: ""}}, link: GetLinks().Profile, payload: map[string]string{"email": "mockuser@example.tld", "error": "not allowed to update this user", "handle": "handle", "name": "name"}, fn: func(_ *settings.Settings) { diff --git a/auth/handlers/handle_security_test.go b/auth/handlers/handle_security_test.go index 719f09e11..e5c6db3e8 100644 --- a/auth/handlers/handle_security_test.go +++ b/auth/handlers/handle_security_test.go @@ -158,5 +158,5 @@ func Test_securityProcDisableEmailOTPSuccess(t *testing.T) { err := authHandlers.securityProc(authReq) rq.NoError(err) - rq.Equal([]request.Alert{{Type: "primary", Text: "Two factor authentication with TOTP disabled", Html: ""}}, authReq.NewAlerts) + rq.Equal([]request.Alert{{Type: "primary", Text: "security.TFA-TOTP-disabled", Html: ""}}, authReq.NewAlerts) } diff --git a/auth/handlers/handle_signup.go b/auth/handlers/handle_signup.go index b9af62ada..261667acf 100644 --- a/auth/handlers/handle_signup.go +++ b/auth/handlers/handle_signup.go @@ -34,7 +34,7 @@ func (h *AuthHandlers) signupProc(req *request.AuthReq) error { t := translator(req, "auth") req.NewAlerts = append(req.NewAlerts, request.Alert{ Type: "primary", - Text: t("singup.alerts.singup-successful"), + Text: t("signup.alerts.signup-successful"), }) h.Log.Info( @@ -105,7 +105,7 @@ func (h *AuthHandlers) confirmEmail(req *request.AuthReq) (err error) { t := translator(req, "auth") req.NewAlerts = append(req.NewAlerts, request.Alert{ Type: "primary", - Text: t("singup.alerts.email-confirmed-logged-in"), + Text: t("signup.alerts.email-confirmed-logged-in"), }) req.RedirectTo = GetLinks().Profile @@ -135,7 +135,7 @@ func (h *AuthHandlers) confirmEmail(req *request.AuthReq) (err error) { t := translator(req, "auth") req.NewAlerts = append(req.NewAlerts, request.Alert{ Type: "warning", - Text: t("singup.alerts.inv-or-exp-token"), + Text: t("signup.alerts.inv-or-exp-token"), }) return nil @@ -157,6 +157,6 @@ func (h *AuthHandlers) signupDisabledAlert(req *request.AuthReq) { t := translator(req, "auth") req.NewAlerts = append(req.NewAlerts, request.Alert{ Type: "danger", - Text: t("singup.alerts.singup-disabled"), + Text: t("signup.alerts.signup-disabled"), }) } diff --git a/auth/handlers/handle_signup_test.go b/auth/handlers/handle_signup_test.go index 0e4fe033b..fbe56f1b6 100644 --- a/auth/handlers/handle_signup_test.go +++ b/auth/handlers/handle_signup_test.go @@ -67,7 +67,7 @@ func Test_signupProc(t *testing.T) { { name: "success email confirmed", err: "", - alerts: []request.Alert{{Type: "primary", Text: "Sign-up successful.", Html: ""}}, + alerts: []request.Alert{{Type: "primary", Text: "signup.alerts.signup-successful", Html: ""}}, link: GetLinks().Profile, payload: map[string]string(nil), fn: func(_ *settings.Settings) { @@ -105,7 +105,7 @@ func Test_signupProc(t *testing.T) { { name: "internal signup disabled", err: "", - alerts: []request.Alert{{Type: "danger", Text: "Signup disabled", Html: ""}}, + alerts: []request.Alert{{Type: "danger", Text: "signup.alerts.signup-disabled", Html: ""}}, link: GetLinks().Login, payload: map[string]string(nil), fn: func(_ *settings.Settings) { diff --git a/pkg/errors/http_test.go b/pkg/errors/http_test.go index ae25b9a5d..ba7efb0d7 100644 --- a/pkg/errors/http_test.go +++ b/pkg/errors/http_test.go @@ -1,6 +1,7 @@ package errors import ( + "context" "fmt" "os" ) @@ -14,7 +15,7 @@ func Example_writeHttpPlain() { } func Example_writeHttpJSON() { - writeHttpJSON(os.Stdout, fmt.Errorf("dummy error"), true) + writeHttpJSON(context.Background(), os.Stdout, fmt.Errorf("dummy error"), true) // Output: // {"error":{"message":"dummy error"}} @@ -34,7 +35,7 @@ func Example_writeHttpPlain_2() { func Example_writeHttpJSON_2() { err := New(0, "dummy error", Meta("a", "b"), Meta(&Error{}, "nope")) err.stack = nil // will not test the stack as file path & line numbers might change - writeHttpJSON(os.Stdout, err, false) + writeHttpJSON(context.Background(), os.Stdout, err, false) // Output: // {"error":{"message":"dummy error","meta":{"a":"b"}}} diff --git a/pkg/locale/locale.go b/pkg/locale/locale.go index c58cf1cc5..50f9c90eb 100644 --- a/pkg/locale/locale.go +++ b/pkg/locale/locale.go @@ -149,8 +149,10 @@ func (set *Languages) Get(ctx context.Context, ns, key string, rr ...string) str } func (set *Languages) get(code language.Tag, ns, key string, rr ...string) string { - if l, has := set.ll[code]; has { - return l.get(ns, key, rr...) + if set != nil && set.ll != nil { + if l, has := set.ll[code]; has { + return l.get(ns, key, rr...) + } } return key diff --git a/store/tests/compose_records_test.go b/store/tests/compose_records_test.go index a3f7fd84d..b693b2f87 100644 --- a/store/tests/compose_records_test.go +++ b/store/tests/compose_records_test.go @@ -1120,7 +1120,7 @@ func testComposeRecords(t *testing.T, s store.ComposeRecords) { f.Limit = 100 _, f, err = store.SearchComposeRecords(ctx, s, mod, f) - req.Error(err, "not allowed to sort by multi-value fields: strMulti") + req.Error(err, "by.errors.notAllowedToSort multi-value fields: strMulti") }) t.Run("advanced sorting; NULL; record value + sys fields", func(t *testing.T) { diff --git a/tests/automation/trigger_test.go b/tests/automation/trigger_test.go index 8af480d49..5121a6f18 100644 --- a/tests/automation/trigger_test.go +++ b/tests/automation/trigger_test.go @@ -132,7 +132,7 @@ func TestTriggerCreate(t *testing.T) { helpers.DenyMe(h, wf.RbacResource(), "triggers.manage") req().Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to create triggers")). + Assert(helpers.AssertError("trigger.errors.notAllowedToCreate")). End() }) } @@ -233,7 +233,7 @@ func TestTriggerUpdate(t *testing.T) { helpers.DenyMe(h, wf.RbacResource(), "triggers.manage") req(tg2.ID, "bar").Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this trigger")). + Assert(helpers.AssertError("trigger.errors.notAllowedToUpdate")). End() res := h.lookupTriggerByID(tg2.ID) @@ -253,7 +253,7 @@ func TestTriggerDeleteForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to delete this trigger")). + Assert(helpers.AssertError("trigger.errors.notAllowedToDelete")). End() res = h.lookupTriggerByID(res.ID) diff --git a/tests/automation/workflow_test.go b/tests/automation/workflow_test.go index 2fa132e09..b0d076c46 100644 --- a/tests/automation/workflow_test.go +++ b/tests/automation/workflow_test.go @@ -128,7 +128,7 @@ func TestWorkflowCreateForbidden(t *testing.T) { FormData("name", rs()). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to create workflows")). + Assert(helpers.AssertError("workflow.errors.notAllowedToCreate")). End() } @@ -145,7 +145,7 @@ func TestWorkflowCreateNotUnique(t *testing.T) { FormData("handle", workflow.Handle). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("workflow handle not unique")). + Assert(helpers.AssertError("workflow.errors.handleNotUnique")). End() } @@ -246,7 +246,7 @@ func TestWorkflowUpdateForbidden(t *testing.T) { FormData("email", rs()). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this workflow")). + Assert(helpers.AssertError("workflow.errors.notAllowedToUpdate")). End() } @@ -282,7 +282,7 @@ func TestWorkflowDeleteForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to delete this workflow")). + Assert(helpers.AssertError("workflow.errors.notAllowedToDelete")). End() } diff --git a/tests/compose/chart_test.go b/tests/compose/chart_test.go index d9e695708..b471fa0c0 100644 --- a/tests/compose/chart_test.go +++ b/tests/compose/chart_test.go @@ -128,7 +128,7 @@ func TestChartCreateForbidden(t *testing.T) { FormData("name", "some-chart"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to create charts")). + Assert(helpers.AssertError("chart.errors.notAllowedToCreate")). End() } @@ -164,7 +164,7 @@ func TestChartUpdateForbidden(t *testing.T) { FormData("name", "changed-name"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this chart")). + Assert(helpers.AssertError("chart.errors.notAllowedToUpdate")). End() } @@ -204,7 +204,7 @@ func TestChartDeleteForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to delete this chart")). + Assert(helpers.AssertError("chart.errors.notAllowedToDelete")). End() } diff --git a/tests/compose/module_test.go b/tests/compose/module_test.go index 677dd5cbf..f2500b27d 100644 --- a/tests/compose/module_test.go +++ b/tests/compose/module_test.go @@ -170,7 +170,7 @@ func TestModuleCreateForbidden(t *testing.T) { FormData("name", "some-module"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to create modules")). + Assert(helpers.AssertError("module.errors.notAllowedToCreate")). End() } @@ -206,7 +206,7 @@ func TestModuleUpdateForbidden(t *testing.T) { FormData("name", "changed-name"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this module")). + Assert(helpers.AssertError("module.errors.notAllowedToUpdate")). End() } @@ -621,7 +621,7 @@ func TestModuleDeleteForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to delete this module")). + Assert(helpers.AssertError("module.errors.notAllowedToDelete")). End() } diff --git a/tests/compose/namespace_test.go b/tests/compose/namespace_test.go index ea762518e..806cad85a 100644 --- a/tests/compose/namespace_test.go +++ b/tests/compose/namespace_test.go @@ -120,7 +120,7 @@ func TestNamespaceCreateForbidden(t *testing.T) { FormData("name", "some-namespace"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to create namespaces")). + Assert(helpers.AssertError("namespace.errors.notAllowedToCreate")). End() } @@ -151,7 +151,7 @@ func TestNamespaceUpdateForbidden(t *testing.T) { FormData("name", "changed-name"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this namespace")). + Assert(helpers.AssertError("namespace.errors.notAllowedToUpdate")). End() } @@ -188,7 +188,7 @@ func TestNamespaceDeleteForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to delete this namespace")). + Assert(helpers.AssertError("namespace.errors.notAllowedToDelete")). End() } diff --git a/tests/compose/page_test.go b/tests/compose/page_test.go index f49860795..ee115faf2 100644 --- a/tests/compose/page_test.go +++ b/tests/compose/page_test.go @@ -140,7 +140,7 @@ func TestPageCreateForbidden(t *testing.T) { FormData("title", "some-page"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to create pages")). + Assert(helpers.AssertError("page.errors.notAllowedToCreate")). End() } @@ -176,7 +176,7 @@ func TestPageUpdateForbidden(t *testing.T) { FormData("title", "changed-name"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this page")). + Assert(helpers.AssertError("page.errors.notAllowedToUpdate")). End() } @@ -233,7 +233,7 @@ func TestPageDeleteForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to delete this page")). + Assert(helpers.AssertError("page.errors.notAllowedToDelete")). End() } diff --git a/tests/compose/record_test.go b/tests/compose/record_test.go index aa9c7bf14..b34385bfd 100644 --- a/tests/compose/record_test.go +++ b/tests/compose/record_test.go @@ -266,7 +266,7 @@ func TestRecordCreateForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to create records")). + Assert(helpers.AssertError("record.errors.notAllowedToCreate")). End() } @@ -438,7 +438,7 @@ func TestRecordUpdateForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this record")). + Assert(helpers.AssertError("record.errors.notAllowedToUpdate")). End() } @@ -704,7 +704,7 @@ func TestRecordDeleteForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to delete this record")). + Assert(helpers.AssertError("record.errors.notAllowedToDelete")). End() } @@ -899,7 +899,7 @@ func TestRecordImportRun_sessionNotFound(t *testing.T) { // r.JSON(rsp) // h.apiRunRecordImport(api, fmt.Sprintf("%s/%s", url, rsp.Response.SessionID), `{"fields":{"fname":"name","femail":"email"},"onError":"fail"}`). -// Assert(helpers.AssertErrorP("not allowed to create records for module")). +// Assert(helpers.AssertErrorP("record.errors.notAllowedToCreate for module")). // End() // }) // } diff --git a/tests/system/application_test.go b/tests/system/application_test.go index 2ace57e9a..51646843d 100644 --- a/tests/system/application_test.go +++ b/tests/system/application_test.go @@ -147,7 +147,7 @@ func TestApplicationCreateForbidden(t *testing.T) { FormData("name", rs()). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to create applications")). + Assert(helpers.AssertError("application.errors.notAllowedToCreate")). End() } @@ -194,7 +194,7 @@ func TestApplicationUpdateForbidden(t *testing.T) { FormData("email", h.randEmail()). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this application")). + Assert(helpers.AssertError("application.errors.notAllowedToUpdate")). End() } @@ -259,7 +259,7 @@ func TestApplicationReorder_forbidden(t *testing.T) { JSON(fmt.Sprintf(`{ "applicationIDs": ["%d", "%d", "%d"] }`, b.ID, a.ID, c.ID)). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this application")). + Assert(helpers.AssertError("application.errors.notAllowedToUpdate")). End() } @@ -299,7 +299,7 @@ func TestApplicationDeleteForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to delete this application")). + Assert(helpers.AssertError("application.errors.notAllowedToDelete")). End() } @@ -455,7 +455,7 @@ func TestApplicationFlags(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to manage global flags for applications")). + Assert(helpers.AssertError("application.errors.notAllowedToManageFlagGlobal")). End() }) @@ -488,7 +488,7 @@ func TestApplicationFlags(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to manage flags for applications")). + Assert(helpers.AssertError("application.errors.notAllowedToManageFlag")). End() }) diff --git a/tests/system/reminder_test.go b/tests/system/reminder_test.go index 106b76ce7..9d2c2e94d 100644 --- a/tests/system/reminder_test.go +++ b/tests/system/reminder_test.go @@ -65,7 +65,7 @@ func TestReminderAssign_forbidden(t *testing.T) { FormData("assignedTo", "404"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to assign reminders to other users")). + Assert(helpers.AssertError("reminder.errors.notAllowedToAssign")). End() } @@ -114,7 +114,7 @@ func TestReminderReadForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to read reminders of other users")). + Assert(helpers.AssertError("reminder.errors.notAllowedToRead")). End() } @@ -146,7 +146,7 @@ func TestReminderUpdateForbidden(t *testing.T) { FormData("resource", "changed:resource"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to assign reminders to other users")). + Assert(helpers.AssertError("reminder.errors.notAllowedToAssign")). End() } @@ -211,7 +211,7 @@ func TestReminderDismissForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to dismiss reminders of other users")). + Assert(helpers.AssertError("reminder.errors.notAllowedToDismiss")). End() } diff --git a/tests/system/role_test.go b/tests/system/role_test.go index f73a59739..c927a69fa 100644 --- a/tests/system/role_test.go +++ b/tests/system/role_test.go @@ -141,7 +141,7 @@ func TestRoleCreateForbidden(t *testing.T) { FormData("name", rs()). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to create roles")). + Assert(helpers.AssertError("role.errors.notAllowedToCreate")). End() } @@ -157,7 +157,7 @@ func TestRoleCreateNotUnique(t *testing.T) { FormData("handle", role.Handle). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("role handle not unique")). + Assert(helpers.AssertError("role.errors.handleNotUnique")). End() h.apiInit(). @@ -167,7 +167,7 @@ func TestRoleCreateNotUnique(t *testing.T) { FormData("handle", "handle_"+rs()). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("role name not unique")). + Assert(helpers.AssertError("role.errors.nameNotUnique")). End() } @@ -277,7 +277,7 @@ func TestRoleUpdateForbidden(t *testing.T) { FormData("email", h.randEmail()). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this role")). + Assert(helpers.AssertError("role.errors.notAllowedToUpdate")). End() } @@ -313,7 +313,7 @@ func TestRoleDeleteForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to delete this role")). + Assert(helpers.AssertError("role.errors.notAllowedToDelete")). End() } diff --git a/tests/system/template_test.go b/tests/system/template_test.go index a8abebd94..395f8c617 100644 --- a/tests/system/template_test.go +++ b/tests/system/template_test.go @@ -119,7 +119,7 @@ func TestTemplateCreateForbidden(t *testing.T) { FormData("handle", rs()). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to create templates")). + Assert(helpers.AssertError("template.errors.notAllowedToCreate")). End() } @@ -150,7 +150,7 @@ func TestTemplateUpdateForbidden(t *testing.T) { FormData("handle", rs()). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this template")). + Assert(helpers.AssertError("template.errors.notAllowedToUpdate")). End() } @@ -188,7 +188,7 @@ func TestTemplateDeleteForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to delete this template")). + Assert(helpers.AssertError("template.errors.notAllowedToDelete")). End() } @@ -247,7 +247,7 @@ func TestTemplateRenderForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to render this template")). + Assert(helpers.AssertError("template.errors.notAllowedToRender")). End() } diff --git a/tests/system/user_test.go b/tests/system/user_test.go index d5e6f4088..1f1200544 100644 --- a/tests/system/user_test.go +++ b/tests/system/user_test.go @@ -326,7 +326,7 @@ func TestUserCreateForbidden(t *testing.T) { FormData("email", h.randEmail()). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to create users")). + Assert(helpers.AssertError("user.errors.notAllowedToCreate")). End() } @@ -360,7 +360,7 @@ func TestUserUpdateForbidden(t *testing.T) { FormData("email", h.randEmail()). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to update this user")). + Assert(helpers.AssertError("user.errors.notAllowedToUpdate")). End() } @@ -448,7 +448,7 @@ func TestUserDeleteForbidden(t *testing.T) { Header("Accept", "application/json"). Expect(t). Status(http.StatusOK). - Assert(helpers.AssertError("not allowed to delete this user")). + Assert(helpers.AssertError("user.errors.notAllowedToDelete")). End() }