Fix tests (use translation keys)

This commit is contained in:
Denis Arh
2021-08-23 19:10:21 +02:00
parent ddef6ed5b4
commit af09848dd8
25 changed files with 96 additions and 90 deletions
+16 -16
View File
@@ -1,6 +1,6 @@
{{ template "inc_header.html.tpl" . }}
<div class="card-body p-0">
<h1 class="h4 card-title p-3 border-bottom">{{ tr "singup.template.title" }}</h1>
<h1 class="h4 card-title p-3 border-bottom">{{ tr "signup.template.title" }}</h1>
<form
method="POST"
action="{{ links.Signup }}"
@@ -15,67 +15,67 @@
<div class="mb-3">
<label>
{{ tr "singup.template.form.email.label" }}
{{ tr "signup.template.form.email.label" }}
</label>
<input
type="email"
class="form-control"
name="email"
required
placeholder="{{ tr "singup.template.form.email.placeholder" }}"
placeholder="{{ tr "signup.template.form.email.placeholder" }}"
autocomplete="username"
value="{{ .form.email }}"
aria-label="{{ tr "singup.template.form.email.aria-label" }}">
aria-label="{{ tr "signup.template.form.email.aria-label" }}">
</div>
<div class="mb-3">
<label>
{{ tr "singup.template.form.password.label" }}
{{ tr "signup.template.form.password.label" }}
</label>
<input
type="password"
class="form-control"
name="password"
required
placeholder="{{ tr "singup.template.form.password.placeholder" }}"
placeholder="{{ tr "signup.template.form.password.placeholder" }}"
autocomplete="new-password"
aria-label="{{ tr "singup.template.form.password.aria-label" }}">
aria-label="{{ tr "signup.template.form.password.aria-label" }}">
</div>
<div class="mb-3">
<label>
{{ tr "singup.template.form.name.label" }}
{{ tr "signup.template.form.name.label" }}
</label>
<input
type="text"
class="form-control"
name="name"
placeholder="{{ tr "singup.template.form.name.placeholder" }}"
placeholder="{{ tr "signup.template.form.name.placeholder" }}"
value="{{ .form.name }}"
autocomplete="name"
aria-label="{{ tr "singup.template.form.name.aria-label" }}">
aria-label="{{ tr "signup.template.form.name.aria-label" }}">
</div>
<div class="mb-3">
<label>
{{ tr "singup.template.form.nickname.label" }}
{{ tr "signup.template.form.nickname.label" }}
</label>
<input
type="text"
class="form-control handle-mask"
name="handle"
placeholder="{{ tr "singup.template.form.nickname.placeholder" }}"
placeholder="{{ tr "signup.template.form.nickname.placeholder" }}"
value="{{ .form.handle }}"
autocomplete="handle"
aria-label="{{ tr "singup.template.form.nickname.aria-label" }}">
aria-label="{{ tr "signup.template.form.nickname.aria-label" }}">
</div>
<div>
<button
id="submit"
class="btn btn-primary btn-block btn-lg"
type="submit"
>{{ tr "singup.template.form.button.sign-up" }}</button>
>{{ tr "signup.template.form.button.sign-up" }}</button>
</div>
</form>
<div class="text-center my-3">{{ tr "singup.template.form.link.alternative" }}
<a href="{{ links.Login }}">{{ tr "singup.template.form.link.login" }}</a>
<div class="text-center my-3">{{ tr "signup.template.form.link.alternative" }}
<a href="{{ links.Login }}">{{ tr "signup.template.form.link.login" }}</a>
</div>
</div>
{{ template "inc_footer.html.tpl" . }}
+3
View File
@@ -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
+1 -1
View File
@@ -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{
+3 -3
View File
@@ -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) {
+2 -2
View File
@@ -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")
+4 -4
View File
@@ -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{
+7 -7
View File
@@ -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) {
+1 -1
View File
@@ -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)
}
+4 -4
View File
@@ -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"),
})
}
+2 -2
View File
@@ -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) {
+3 -2
View File
@@ -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"}}}
+4 -2
View File
@@ -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
+1 -1
View File
@@ -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) {
+3 -3
View File
@@ -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)
+4 -4
View File
@@ -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()
}
+3 -3
View File
@@ -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()
}
+3 -3
View File
@@ -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()
}
+3 -3
View File
@@ -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()
}
+3 -3
View File
@@ -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()
}
+4 -4
View File
@@ -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()
// })
// }
+6 -6
View File
@@ -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()
})
+4 -4
View File
@@ -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()
}
+5 -5
View File
@@ -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()
}
+4 -4
View File
@@ -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()
}
+3 -3
View File
@@ -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()
}