Skip to content

Commit

Permalink
fixed for github (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
noamd-legit committed Dec 4, 2023
1 parent 26bba31 commit 6ea81a7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion policies/github/member.rego
Expand Up @@ -15,7 +15,7 @@ package member
default organization_has_too_many_admins := true

organization_has_too_many_admins := false {
admins := count({member | member := input.members[_]; member.is_admin == true})
admins := count([member | member := input.members[_]; member.is_admin == true])
admins <= 3
}

Expand Down
33 changes: 32 additions & 1 deletion test/member_test.go
@@ -1,10 +1,11 @@
package test

import (
"github.com/Legit-Labs/legitify/internal/common/scm_type"
"testing"
"time"

"github.com/Legit-Labs/legitify/internal/common/scm_type"

githubcollected "github.com/Legit-Labs/legitify/internal/collected/github"
"github.com/Legit-Labs/legitify/internal/common/namespace"
)
Expand Down Expand Up @@ -84,6 +85,36 @@ func TestMember(t *testing.T) {
},
},
},
{
name: "should find too many admins",
policyName: "organization_has_too_many_admins",
shouldBeViolated: true,
args: memberMockConfiguration{
hasLastActive: true,
members: []githubcollected.OrganizationMember{
{
LastActive: int(time.Now().AddDate(0, -1, 0).UnixNano()),
IsAdmin: true,
},
{
LastActive: int(time.Now().AddDate(0, -1, 0).UnixNano()),
IsAdmin: true,
},
{
LastActive: int(time.Now().AddDate(0, -1, 0).UnixNano()),
IsAdmin: true,
},
{
LastActive: int(time.Now().AddDate(0, -1, 0).UnixNano()),
IsAdmin: true,
},
{
LastActive: int(time.Now().AddDate(0, -1, 0).UnixNano()),
IsAdmin: true,
},
},
},
},
}

for _, test := range tests {
Expand Down

0 comments on commit 6ea81a7

Please sign in to comment.