# yaml-language-server: $schema=https://api.cerbos.dev/latest/cerbos/policy/v1/TestSuite.schema.json
---
resources:
  english_language:
    id: english_language
    kind: language

name: LanguageTestSuite
description: Tests for the language resource policy and machine principal policy
tests:
  - name: lambda-content-store-product-metadata can view language resources
    input:
      principals:
        - lambda-content-store-product-metadata
        - some_hacker
      resources:
        - english_language
      actions:
        - view
    expected:
      - principal: lambda-content-store-product-metadata
        resource: english_language
        actions:
          view: EFFECT_ALLOW
      - principal: some_hacker
        resource: english_language
        actions:
          view: EFFECT_DENY
  - name: lambda-content-index-add-product can view language resources
    input:
      principals:
        - lambda-content-index-add-product
        - some_hacker
      resources:
        - english_language
      actions:
        - view
    expected:
      - principal: lambda-content-index-add-product
        resource: english_language
        actions:
          view: EFFECT_ALLOW
      - principal: some_hacker
        resource: english_language
        actions:
          view: EFFECT_DENY
  - name: users with content_can_review_digital_audio can view language resources
    input:
      principals:
        - reviewer_1
        - reviewer_2
        - some_hacker
      resources:
        - english_language
      actions:
        - view
    expected:
      - principal: reviewer_1
        resource: english_language
        actions:
          view: EFFECT_ALLOW
      - principal: reviewer_2
        resource: english_language
        actions:
          view: EFFECT_ALLOW
      - principal: some_hacker
        resource: english_language
        actions:
          view: EFFECT_DENY
  - name: users with content_ccm_digital_audio_can_bulk_create can view language resources
    input:
      principals:
        - bulk_creator_1
        - bulk_creator_2
        - some_hacker
      resources:
        - english_language
      actions:
        - view
    expected:
      - principal: bulk_creator_1
        resource: english_language
        actions:
          view: EFFECT_ALLOW
      - principal: bulk_creator_2
        resource: english_language
        actions:
          view: EFFECT_ALLOW
      - principal: some_hacker
        resource: english_language
        actions:
          view: EFFECT_DENY
