simonw / datasette-edit-schema

Datasette plugin for modifying table schemas
Apache License 2.0
16 stars 0 forks source link

Tests that demonstrate table-level permissions #59

Closed simonw closed 7 months ago

simonw commented 7 months ago

I built this for:

But in writing the release notes (#58) I realized the tests don't actually cover this yet. The documentation should mention it too.

simonw commented 7 months ago

I first did a round of manual testing:

sqlite-utils create-database sales.db
sqlite-utils create-database marketing.db
sqlite-utils create-table sales.db notes id integer --pk id
sqlite-utils create-table sales.db customers id integer --pk id
datasette -c perms.yml sales.db marketing.db --secret 1 --reload

Where perms.yml contained:

databases:
  marketing:
    permissions:
      create-table:
        id: pelican
      drop-table:
        id: pelican
      alter-table:
        id: pelican
  sales:
    tables:
      notes:
        permissions:
          alter-table:
            id: pelican

And I used a new datasette-unsafe-actor-debug plugin to help test.

This worked, though it did show me I need to fix this: