diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 61d687a..eb22ab3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -39,21 +39,8 @@ jobs: test: runs-on: ubuntu-latest - # Define any services needed for the test suite (or delete this section) - # services: - # postgres: - # image: postgres:16 - # ports: - # - "5432:5432" - # env: - # POSTGRES_PASSWORD: secretpassword env: BATON_LOG_LEVEL: debug - # Add any environment variables needed to run baton-formal - # BATON_BASE_URL: 'http://localhost:8080' - # BATON_ACCESS_TOKEN: 'secret_token' - # The following parameters are passed to grant/revoke commands - # Change these to the correct IDs for your test data BATON_FORMAL_API_KEY: ${{ secrets.BATON_FORMAL_API_KEY }} CONNECTOR_GRANT: 'group:group_01hwv4ketae9vsa36rafvkn8mr:member:user:user_01hw3ydazpetds0xzgayvpc2vw' CONNECTOR_ENTITLEMENT: 'group:group_01hwv4ketae9vsa36rafvkn8mr:member' @@ -66,14 +53,6 @@ jobs: go-version: 1.22.x - name: Checkout code uses: actions/checkout@v4 - # Install any dependencies here (or delete this) - # - name: Install postgres client - # run: sudo apt install postgresql-client - # Run any fixture setup here (or delete this) - # - name: Import sql into postgres - # run: psql -h localhost --user postgres -f environment.sql - # env: - # PGPASSWORD: secretpassword - name: Build baton-formal run: go build ./cmd/baton-formal - name: Run baton-formal @@ -83,11 +62,9 @@ jobs: run: ./scripts/get-baton.sh && mv baton /usr/local/bin - name: Check for grant before revoking - run: baton grants --entitlement="${{ env.CONNECTOR_ENTITLEMENT }}" --output-format=json | jq --exit-status ".grants[].principal.id.resource == \"${{ env.CONNECTOR_PRINCIPAL }}\"" - - name: Revoke grants run: ./baton-formal --revoke-grant="${{ env.CONNECTOR_GRANT }}" diff --git a/pkg/connector/groups.go b/pkg/connector/groups.go index 448c16a..2412fa1 100644 --- a/pkg/connector/groups.go +++ b/pkg/connector/groups.go @@ -17,6 +17,8 @@ import ( "go.uber.org/zap" ) +const PageSize = 100 + type groupBuilder struct { client *sdk.FormalSDK } @@ -27,7 +29,7 @@ func (o *groupBuilder) ResourceType(ctx context.Context) *v2.ResourceType { func (o *groupBuilder) List(ctx context.Context, parentResourceID *v2.ResourceId, pToken *pagination.Token) ([]*v2.Resource, string, annotations.Annotations, error) { request := connect.NewRequest(&corev1.ListGroupsRequest{ - Limit: 100, + Limit: PageSize, Cursor: pToken.Token, }) @@ -72,7 +74,7 @@ func (o *groupBuilder) Entitlements(_ context.Context, resource *v2.Resource, _ func (o *groupBuilder) Grants(ctx context.Context, resource *v2.Resource, pToken *pagination.Token) ([]*v2.Grant, string, annotations.Annotations, error) { request := connect.NewRequest(&corev1.ListUserGroupLinksRequest{ GroupId: resource.Id.Resource, - Limit: 100, + Limit: PageSize, Cursor: pToken.Token, }) @@ -166,7 +168,7 @@ func (o *groupBuilder) Revoke(ctx context.Context, grant *v2.Grant) (annotations for { request := connect.NewRequest(&corev1.ListUserGroupLinksRequest{ GroupId: grant.Entitlement.Resource.Id.Resource, - Limit: 100, + Limit: PageSize, Cursor: npt, })