# yaml-language-server: $schema=https://api.cerbos.dev/latest/cerbos/policy/v1/TestSuite.schema.json
---
name: DemoCheckFeatureControlTestSuite
description: Tests for verifying the demo_check_feature_control resource policy
tests:
  - name: Hyping allowed when workstation_catalog on resource tenant and feature flag is ON
    input:
      principals:
        - alex
      resources:
        - demo_check_fc_flag_on
      actions:
        - hype
    expected:
      - principal: alex
        resource: demo_check_fc_flag_on
        actions:
          hype: EFFECT_ALLOW

  - name: Hyping denied when workstation_catalog on resource tenant but feature flag is OFF
    input:
      principals:
        - alex
      resources:
        - demo_check_fc_flag_off
      actions:
        - hype
    expected:
      - principal: alex
        resource: demo_check_fc_flag_off
        actions:
          hype: EFFECT_DENY

  - name: Hyping allowed when workstation_catalog via tenant hierarchy and feature flag is ON
    input:
      principals:
        - morgan
      resources:
        - demo_check_fc_flag_on
      actions:
        - hype
    expected:
      - principal: morgan
        resource: demo_check_fc_flag_on
        actions:
          hype: EFFECT_ALLOW

  - name: Hyping denied without workstation_catalog role even when feature flag is ON
    input:
      principals:
        - jess
      resources:
        - demo_check_fc_flag_on
      actions:
        - hype
    expected:
      - principal: jess
        resource: demo_check_fc_flag_on
        actions:
          hype: EFFECT_DENY
