<commit_before>#! /bin/bash
set -o errexit

# executed for varied service endpoint and content/accept media types,
# with expected variations in the available options
# nb. -D - means no data

# gsp
curl_graph_store_get -D - -X OPTIONS \
   | fgrep "Allow" | fgrep GET | fgrep -q DELETE

# there are no restrictions on request media type
curl_graph_store_get -D - -f -s -X OPTIONS \
     -H "Content-Type: application/sparql-query" \
   | fgrep "Allow" | fgrep GET | fgrep PUT | fgrep POST | fgrep -q DELETE

# there are no restrictions on response media type
curl_graph_store_get -D - -f -s -X OPTIONS \
     -H "Accept: application/sparql-results+xml" \
   | fgrep "Allow" | fgrep PUT | fgrep POST | fgrep -q DELETE<commit_msg>add preflight options test<commit_after>#! /bin/bash
set -o errexit

# executed for varied service endpoint and content/accept media types,
# with expected variations in the available options
# nb. -D - means no data

# gsp
curl_graph_store_get -D - -X OPTIONS \
   | fgrep "Allow" | fgrep GET | fgrep -q DELETE

# there are no restrictions on request media type
curl_graph_store_get -D - -f -s -X OPTIONS \
     -H "Content-Type: application/sparql-query" \
   | fgrep "Allow" | fgrep GET | fgrep PUT | fgrep POST | fgrep -q DELETE

# there are no restrictions on response media type
curl_graph_store_get -D - -f -s -X OPTIONS \
     -H "Accept: application/sparql-results+xml" \
   | fgrep "Allow" | fgrep PUT | fgrep POST | fgrep -q DELETE


# verify that headers for a 401 are those required by preflight requests
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin

STORE_TOKEN="not valid" curl_graph_store_get -D - -f -s -X OPTIONS \
  --repository "system" \
  --account "system" \
  | tr '\n' ' ' | tr '\r' ' ' \
  | fgrep 'Access-Control-Allow-Origin' \
  | fgrep 'Access-Control-Allow-Credentials' \
  | fgrep -q 401
{'fraction_non_alphanumeric': 0.11363636363636363, 'fraction_numerical': 0.0030303030303030303, 'mean_word_length': 3.135699373695198, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1778436', 'n_tokens_mistral': 728, 'n_tokens_neox': 699, 'n_words': 223}