Skip to content

Commit fbf4db1

Browse files
committed
fix: Fix nil permissions as Strings()
1 parent 1f04c01 commit fbf4db1

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

coderd/authz/authztest/group.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package authztest
22

3+
// PermissionSet defines a set of permissions with the same impact.
34
type PermissionSet string
45

56
const (

coderd/authz/authztest/group_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,10 @@ func Test_PermissionSetWPlusSearchSpace(t *testing.T) {
2828
for k, v := range all {
2929
fmt.Printf("%s=%d\n", string(k), len(v.All()))
3030
}
31+
32+
var i int
33+
wplus.Each(func(set Set) {
34+
fmt.Printf("%d: %s\n", i, set.String())
35+
i++
36+
})
3137
}

coderd/authz/authztest/iterator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (si *unionIterator) Next() bool {
5151
si.offset = 0
5252
}
5353

54-
return si.setIdx >= len(si.sets)
54+
return si.setIdx < len(si.sets)
5555
}
5656

5757
func (si *unionIterator) Permissions() Set {

coderd/authz/authztest/role.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ func (r *Role) Permissions() Set {
4444
for _, ps := range r.PermissionSets {
4545
i += copy(r.buffer[i:], ps.Permissions())
4646
}
47-
//all := make(Set, 0, r.ReturnSize)
48-
//for _, set := range r.PermissionSets {
49-
// all = append(all, set.Permissions()...)
50-
//}
5147
return r.buffer
5248
}
5349

coderd/authz/authztest/set.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ func (s Set) String() string {
1818
var str strings.Builder
1919
sep := ""
2020
for _, v := range s {
21+
if v == nil {
22+
continue
23+
}
2124
str.WriteString(sep)
2225
str.WriteString(v.String())
2326
sep = ", "

0 commit comments

Comments
 (0)