Add permission intg. tests
This commit is contained in:
@@ -1,9 +1,36 @@
|
||||
package messaging
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/internal/permissions"
|
||||
"github.com/cortezaproject/corteza-server/tests/helpers"
|
||||
)
|
||||
|
||||
func TestPermissionsDelete(t *testing.T) {
|
||||
t.Skip("to be implemented")
|
||||
h := newHelper(t)
|
||||
|
||||
h.a.Empty(p.FindRulesByRoleID(h.roleID))
|
||||
|
||||
h.allow("messaging", "access")
|
||||
h.allow("messaging", "grant")
|
||||
h.deny("messaging", "channel.group.create")
|
||||
|
||||
h.a.Len(p.FindRulesByRoleID(h.roleID), 3)
|
||||
|
||||
h.apiInit().
|
||||
Delete(fmt.Sprintf("/permissions/%d/rules", h.roleID)).
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
|
||||
// Make sure everything is deleted
|
||||
rr, _ := p.FindRulesByRoleID(h.roleID).Filter(func(r *permissions.Rule) (b bool, e error) {
|
||||
return r.Access != permissions.Inherit, nil
|
||||
})
|
||||
|
||||
h.a.Empty(rr)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
package messaging
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/tests/helpers"
|
||||
)
|
||||
|
||||
func TestPermissionsEffective(t *testing.T) {
|
||||
t.Skip("to be implemented")
|
||||
h := newHelper(t)
|
||||
h.allow("messaging", "access")
|
||||
h.deny("messaging", "channel.group.create")
|
||||
|
||||
h.apiInit().
|
||||
Get("/permissions/effective").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
}
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
package messaging
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
jsonpath "github.com/steinfletcher/apitest-jsonpath"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/tests/helpers"
|
||||
)
|
||||
|
||||
func TestPermissionsList(t *testing.T) {
|
||||
t.Skip("to be implemented")
|
||||
h := newHelper(t)
|
||||
|
||||
h.apiInit().
|
||||
Get("/permissions/").
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
Assert(jsonpath.Present(`$.response[? @.resource=="messaging"]`)).
|
||||
End()
|
||||
}
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
package messaging
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/tests/helpers"
|
||||
)
|
||||
|
||||
func TestPermissionsRead(t *testing.T) {
|
||||
t.Skip("to be implemented")
|
||||
h := newHelper(t)
|
||||
h.allow("messaging", "access")
|
||||
h.allow("messaging", "grant")
|
||||
h.deny("messaging", "channel.group.create")
|
||||
|
||||
h.apiInit().
|
||||
Get(fmt.Sprintf("/permissions/%d/rules", h.roleID)).
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
}
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
package messaging
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/tests/helpers"
|
||||
)
|
||||
|
||||
func TestPermissionsUpdate(t *testing.T) {
|
||||
t.Skip("to be implemented")
|
||||
h := newHelper(t)
|
||||
h.allow("messaging", "access")
|
||||
h.allow("messaging", "grant")
|
||||
h.deny("messaging", "channel.group.create")
|
||||
|
||||
h.apiInit().
|
||||
Patch(fmt.Sprintf("/permissions/%d/rules", h.roleID)).
|
||||
JSON(`{"rules":[{"resource":"messaging","operation":"channel.group.create","access":"allow"}]}`).
|
||||
Expect(t).
|
||||
Status(http.StatusOK).
|
||||
Assert(helpers.AssertNoErrors).
|
||||
End()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user