#
# PWG 5100.11-2024: IPP Enterprise Printing Extensions v2.0 (EPX)
#
# https://ftp.pwg.org/pub/pwg/candidates/cs-ippepx20-20240315-5100.11.pdf
#
# Copyright © 2018-2024 by OpenPrinting.
#
# Licensed under Apache License v2.0.  See the file "LICENSE" for more
# information.
#
# Usage:
#
#   ./ipptool [OPTIONS] -f FILENAME -t PRINTER-URI pwg5100.11.test
#
# Options:
#
#   -d NOPRINT=1              Disable the print tests.
#   -d REQUIRE_EPX=1          Require support for the EPX specification.
#

{
    NAME "PWG 5100.11-2024: Operations, Attributes, and Values"
    OPERATION Get-Printer-Attributes
    GROUP operation-attributes-tag
    ATTR charset attributes-charset utf-8
    ATTR language attributes-natural-language en
    ATTR uri printer-uri $uri

    STATUS successful-ok

    # Section 5 - New Operations
    EXPECT operations-supported OF-TYPE enum IN-GROUP printer-attributes-tag
    EXPECT operations-supported WITH-VALUE 0x0038 DEFINE-MATCH PRINTER_HAS_GET_USER_PRINTER_ATTRIBUTES # Get-User-Printer-Attributes

    # Section 6.4 - Printer Description Attributes
    EXPECT ?job-cancel-after-supported OF-TYPE rangeOfInteger(1:MAX) IN-GROUP printer-attributes-tag COUNT 1
    EXPECT job-cancel-after-supported DEFINE-MATCH PRINTER_HAS_JOB_CANCEL_AFTER

    EXPECT ?job-cancel-after-default OF-TYPE integer(1:MAX)|no-value IN-GROUP printer-attribute-tag COUNT 1
    EXPECT job-cancel-after-default IF-DEFINED PRINTER_HAS_JOB_CANCEL_AFTER

    EXPECT ?job-password-supported OF-TYPE integer(0:255) IN-GROUP printer-attributes-tag COUNT 1
    EXPECT job-password-supported DEFINE-MATCH PRINTER_HAS_JOB_PASSWORD

    EXPECT ?job-password-encryption-supported OF-TYPE keyword IN-GROUP printer-attribute-tag
    EXPECT job-password-encryption-supported IF-DEFINED PRINTER_HAS_JOB_PASSWORD

    EXPECT ?job-password-length-supported OF-TYPE rangeOfInteger(4:MAX) IN-GROUP printer-attributes-tag COUNT 1
    EXPECT job-password-length-supported IF-DEFINED PRINTER_HAS_JOB_PASSWORD

    EXPECT ?job-password-repertoire-supported OF-TYPE keyword IN-GROUP printer-attributes-tag
    EXPECT job-password-repertoire-supported IF-DEFINED PRINTER_HAS_JOB_PASSWORD

    EXPECT ?job-password-repertoire-configured OF-TYPE keyword IN-GROUP printer-attributes-tag COUNT 1 WITH-VALUE-FROM job-password-repertoire-supported
    EXPECT job-password-repertoire-configured IF-DEFINED PRINTER_HAS_JOB_PASSWORD

    EXPECT ?job-release-action-supported OF-TYPE keyword IN-GROUP printer-attributes-tag
    EXPECT job-release-action-supported DEFINE-MATCH PRINTER_HAS_JOB_RELEASE_ACTION

    EXPECT ?job-release-action-default OF-TYPE keyword IN-GROUP printer-attributes-tag COUNT 1 WITH-VALUE-FROM job-release-action-supported
    EXPECT job-release-action-default IF-DEFINED PRINTER_HAS_JOB_RELEASE_ACTION

    EXPECT ?job-storage-supported OF-TYPE keyword IN-GROUP printer-attributes-tag
    EXPECT job-storage-supported DEFINE-MATCH PRINTER_HAS_JOB_STORAGE

    EXPECT ?job-storage-access-supported OF-TYPE keyword IN-GROUP printer-attributes-tag
    EXPECT job-storage-access-supported DEFINE-MATCH PRINTER_HAS_JOB_STORAGE

    EXPECT ?job-storage-disposition-supported OF-TYPE keyword IN-GROUP printer-attributes-tag
    EXPECT job-storage-disposition-supported DEFINE-MATCH PRINTER_HAS_JOB_STORAGE

    EXPECT ?job-storage-group-supported OF-TYPE name IN-GROUP printer-attributes-tag
    EXPECT job-storage-group-supported DEFINE-MATCH PRINTER_HAS_JOB_STORAGE

    EXPECT ?printer-asset-tag OF-TYPE octetString IN-GROUP printer-attributes-tag COUNT 1

    EXPECT ?printer-detailed-status-messages OF-TYPE text IN-GROUP printer-attributes-tag

    EXPECT ?printer-service-contact-col OF-TYPE collection|unknown IN-GROUP printer-attributes-tag COUNT 1
    EXPECT printer-service-contact-col IF-DEFINED REQUIRE_EPX

    EXPECT ?proof-copies-supported OF-TYPE rangeOfInteger(1:MAX) IN-GROUP printer-attributes-tag COUNT 1
    EXPECT proof-copies-supported DEFINE-MATCH PRINTER_HAS_PROOF_COPIES

    # Section 6.5 - Printer Status Attributes
    EXPECT ?printer-serial-number OF-TYPE text IN-GROUP printer-attributes-tag COUNT 1
    EXPECT printer-serial-number IF-DEFINED REQUIRE_EPX

    EXPECT ?printer-storage OF-TYPE octetString IN-GROUP printer-attributes-tag SAME-COUNT-AS printer-storage-description
    EXPECT printer-storage IF-DEFINED REQUIRE_EPX

    EXPECT ?printer-storage-description OF-TYPE text IN-GROUP printer-attributes-tag SAME-COUNT-AS printer-storage
    EXPECT printer-storage-description IF-DEFINED REQUIRE_EPX
}

# TODO: Add print tests for various features
