#!/bin/sh
# Sign a CAB file with "low" level of permissions in Microsoft Internet Explorer 4.x for CAB files
# https://support.microsoft.com/en-us/help/193877

. $(dirname $0)/../test_library
script_path=$(pwd)
test_nr=42

for file in ${script_path}/../logs/notsigned/*.*
  do
    name="${file##*/}"
    ext="${file##*.}"
    desc=""
    case $ext in
      "cat") continue;; # Warning: -jp option is only valid for CAB files
      "msi") continue;; # Warning: -jp option is only valid for CAB files
      "ex_") filetype=CAB; format_nr=3 ;;
      "exe") continue;; # Warning: -jp option is only valid for CAB files
      "ps1") continue;; # Warning: -jp option is only valid for CAB files
    esac

    number="$test_nr$format_nr"
    test_name="Sign a $filetype$desc file with the jp low option"
    printf "\n%03d. %s\n" "$number" "$test_name"

    ../../osslsigncode sign -h sha256 \
      -st "1556668800" \
      -jp low \
      -certs "${script_path}/../certs/cert.pem" -key "${script_path}/../certs/key.pem" \
      -in "notsigned/$name" -out "test_$number.$ext"
    result=$?

    verify_signature "$result" "$number" "$ext" "success" "@2019-09-01 12:00:00" \
      "UNUSED_PATTERN" "Low level of permissions" "UNUSED_PATTERN"
    test_result "$?" "$number" "$test_name"
  done

exit 0
