github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/internal/services/integrationtesting/testconfigs/expiration.yaml (about)

     1  ---
     2  schema: |+
     3    definition user {}
     4  
     5    caveat is_not_expired(current_time timestamp, expiration timestamp) {
     6      current_time < expiration
     7    }
     8  
     9    definition document {
    10      relation viewer: user with is_not_expired
    11      permission view = viewer
    12    }
    13  
    14  relationships: >-
    15    document:firstdoc#viewer@user:tracy[is_not_expired:{"expiration":"2024-12-01T00:00:00Z","current_time":"2023-01-01T00:00:00Z"}]
    16  
    17    document:firstdoc#viewer@user:tom[is_not_expired:{"expiration":"2023-12-01T00:00:00Z"}]
    18  
    19    document:firstdoc#viewer@user:fred[is_not_expired:{"expiration":"2022-12-01T00:00:00Z"}]
    20  
    21    document:firstdoc#viewer@user:sarah[is_not_expired:{"expiration":"2023-12-01T00:02:00Z"}]
    22  assertions:
    23    assertTrue:
    24      - 'document:firstdoc#view@user:tracy'
    25      - 'document:firstdoc#view@user:tom with {"current_time":"2022-01-01T00:00:00Z"}'
    26      - 'document:firstdoc#view@user:sarah with {"current_time":"2023-01-01T00:00:00Z"}'
    27    assertCaveated:
    28      - 'document:firstdoc#view@user:tom'
    29      - 'document:firstdoc#view@user:fred'
    30      - 'document:firstdoc#view@user:sarah'
    31    assertFalse:
    32      - 'document:firstdoc#view@user:tom with {"current_time":"2023-12-01T00:01:00Z"}'
    33      - 'document:firstdoc#view@user:fred with {"current_time":"2023-01-01T00:00:00Z"}'