This commit is contained in:
parent
d39a6989d2
commit
b5824ff81f
|
@ -476,58 +476,87 @@ func TestListTask(t *testing.T) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
/*
|
t.Run("Create", func(t *testing.T) {
|
||||||
t.Run("Create", func(t *testing.T) {
|
t.Run("Normal", func(t *testing.T) {
|
||||||
t.Run("Normal", func(t *testing.T) {
|
rec, err := testHandler.testCreate(nil, map[string]string{"list": "1"}, `{"text":"Lorem Ipsum"}`)
|
||||||
rec, err := testHandler.testCreate(nil, map[string]string{"task": ""}, `{}`)
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, err)
|
assert.Contains(t, rec.Body.String(), `"text":"Lorem Ipsum"`)
|
||||||
assert.Contains(t, rec.Body.String(), ``)
|
})
|
||||||
})
|
t.Run("Nonexisting", func(t *testing.T) {
|
||||||
t.Run("Nonexisting", func(t *testing.T) {
|
_, err := testHandler.testCreate(nil, map[string]string{"list": "9999"}, `{"text":"Lorem Ipsum"}`)
|
||||||
_, err := testHandler.testCreate(nil, map[string]string{"task": ""}, `{}`)
|
assert.Error(t, err)
|
||||||
|
assertHandlerErrorCode(t, err, models.ErrCodeListDoesNotExist)
|
||||||
|
})
|
||||||
|
t.Run("Rights check", func(t *testing.T) {
|
||||||
|
t.Run("Forbidden", func(t *testing.T) {
|
||||||
|
// Owned by user3
|
||||||
|
_, err := testHandler.testCreate(nil, map[string]string{"list": "2"}, `{"text":"Lorem Ipsum"}`)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assertHandlerErrorCode(t, err, models.ErrCode)
|
assert.Contains(t, err.(*echo.HTTPError).Message, `Forbidden`)
|
||||||
|
})
|
||||||
|
t.Run("Shared Via Team readonly", func(t *testing.T) {
|
||||||
|
_, err := testHandler.testCreate(nil, map[string]string{"list": "6"}, `{"text":"Lorem Ipsum"}`)
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.Contains(t, err.(*echo.HTTPError).Message, `Forbidden`)
|
||||||
|
})
|
||||||
|
t.Run("Shared Via Team write", func(t *testing.T) {
|
||||||
|
rec, err := testHandler.testCreate(nil, map[string]string{"list": "7"}, `{"text":"Lorem Ipsum"}`)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Contains(t, rec.Body.String(), `"text":"Lorem Ipsum"`)
|
||||||
|
})
|
||||||
|
t.Run("Shared Via Team admin", func(t *testing.T) {
|
||||||
|
rec, err := testHandler.testCreate(nil, map[string]string{"list": "8"}, `{"text":"Lorem Ipsum"}`)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Contains(t, rec.Body.String(), `"text":"Lorem Ipsum"`)
|
||||||
})
|
})
|
||||||
t.Run("Rights check", func(t *testing.T) {
|
|
||||||
|
|
||||||
t.Run("Forbidden", func(t *testing.T) {
|
t.Run("Shared Via User readonly", func(t *testing.T) {
|
||||||
_, err := testHandler.testCreate(nil, map[string]string{"task": ""}, `{}`)
|
_, err := testHandler.testCreate(nil, map[string]string{"list": "9"}, `{"text":"Lorem Ipsum"}`)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Contains(t, err.(*echo.HTTPError).Message, `Forbidden`)
|
assert.Contains(t, err.(*echo.HTTPError).Message, `Forbidden`)
|
||||||
})
|
})
|
||||||
|
t.Run("Shared Via User write", func(t *testing.T) {
|
||||||
|
rec, err := testHandler.testCreate(nil, map[string]string{"list": "10"}, `{"text":"Lorem Ipsum"}`)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Contains(t, rec.Body.String(), `"text":"Lorem Ipsum"`)
|
||||||
|
})
|
||||||
|
t.Run("Shared Via User admin", func(t *testing.T) {
|
||||||
|
rec, err := testHandler.testCreate(nil, map[string]string{"list": "11"}, `{"text":"Lorem Ipsum"}`)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Contains(t, rec.Body.String(), `"text":"Lorem Ipsum"`)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("Shared Via NamespaceTeam readonly", func(t *testing.T) {
|
t.Run("Shared Via NamespaceTeam readonly", func(t *testing.T) {
|
||||||
_, err := testHandler.testCreate(nil, map[string]string{"task": ""}, `{}`)
|
_, err := testHandler.testCreate(nil, map[string]string{"list": "12"}, `{"text":"Lorem Ipsum"}`)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Contains(t, err.(*echo.HTTPError).Message, `Forbidden`)
|
assert.Contains(t, err.(*echo.HTTPError).Message, `Forbidden`)
|
||||||
})
|
})
|
||||||
t.Run("Shared Via NamespaceTeam write", func(t *testing.T) {
|
t.Run("Shared Via NamespaceTeam write", func(t *testing.T) {
|
||||||
rec, err := testHandler.testCreate(nil, map[string]string{"task": ""}, `{}`)
|
rec, err := testHandler.testCreate(nil, map[string]string{"list": "13"}, `{"text":"Lorem Ipsum"}`)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Contains(t, rec.Body.String(), ``)
|
assert.Contains(t, rec.Body.String(), `"text":"Lorem Ipsum"`)
|
||||||
})
|
})
|
||||||
t.Run("Shared Via NamespaceTeam admin", func(t *testing.T) {
|
t.Run("Shared Via NamespaceTeam admin", func(t *testing.T) {
|
||||||
rec, err := testHandler.testCreate(nil, map[string]string{"task": ""}, `{}`)
|
rec, err := testHandler.testCreate(nil, map[string]string{"list": "14"}, `{"text":"Lorem Ipsum"}`)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Contains(t, rec.Body.String(), ``)
|
assert.Contains(t, rec.Body.String(), `"text":"Lorem Ipsum"`)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Shared Via NamespaceUser readonly", func(t *testing.T) {
|
t.Run("Shared Via NamespaceUser readonly", func(t *testing.T) {
|
||||||
_, err := testHandler.testCreate(nil, map[string]string{"task": ""}, `{}`)
|
_, err := testHandler.testCreate(nil, map[string]string{"list": "15"}, `{"text":"Lorem Ipsum"}`)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Contains(t, err.(*echo.HTTPError).Message, `Forbidden`)
|
assert.Contains(t, err.(*echo.HTTPError).Message, `Forbidden`)
|
||||||
})
|
})
|
||||||
t.Run("Shared Via NamespaceUser write", func(t *testing.T) {
|
t.Run("Shared Via NamespaceUser write", func(t *testing.T) {
|
||||||
rec, err := testHandler.testCreate(nil, map[string]string{"task": ""}, `{}`)
|
rec, err := testHandler.testCreate(nil, map[string]string{"list": "16"}, `{"text":"Lorem Ipsum"}`)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Contains(t, rec.Body.String(), ``)
|
assert.Contains(t, rec.Body.String(), `"text":"Lorem Ipsum"`)
|
||||||
})
|
})
|
||||||
t.Run("Shared Via NamespaceUser admin", func(t *testing.T) {
|
t.Run("Shared Via NamespaceUser admin", func(t *testing.T) {
|
||||||
rec, err := testHandler.testCreate(nil, map[string]string{"task": ""}, `{}`)
|
rec, err := testHandler.testCreate(nil, map[string]string{"list": "17"}, `{"text":"Lorem Ipsum"}`)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Contains(t, rec.Body.String(), ``)
|
assert.Contains(t, rec.Body.String(), `"text":"Lorem Ipsum"`)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
*/
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ func (t *ListTask) CanCreate(a web.Auth) (bool, error) {
|
||||||
|
|
||||||
// CanRead determines if a user can read a task
|
// CanRead determines if a user can read a task
|
||||||
func (t *ListTask) CanRead(a web.Auth) (canRead bool, err error) {
|
func (t *ListTask) CanRead(a web.Auth) (canRead bool, err error) {
|
||||||
|
//return t.canDoListTask(a)
|
||||||
// Get the task, error out if it doesn't exist
|
// Get the task, error out if it doesn't exist
|
||||||
*t, err = getTaskByIDSimple(t.ID)
|
*t, err = getTaskByIDSimple(t.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user