-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support tests using template-linked policies #150
Conversation
Signed-off-by: Mike Hicks <mwhicks@amazon.com>
if [ -z "$schema" ] | ||
if [ -z "$schema" -a -z "$links" ] | ||
then | ||
IFS=$'\n' read -r -d '' -a tmp_array < <(cedar authorize --policies "$folder/$policies" --entities "$folder/$entities" --request-json "$file" -v && printf '\0') | ||
else | ||
elif [ -z "$links" ] | ||
then | ||
IFS=$'\n' read -r -d '' -a tmp_array < <(cedar authorize --policies "$folder/$policies" --schema "$folder/$schema" --schema-format human --entities "$folder/$entities" --request-json "$file" -v && printf '\0') | ||
else | ||
IFS=$'\n' read -r -d '' -a tmp_array < <(cedar authorize --policies "$folder/$policies" -k "$folder/$links" --schema "$folder/$schema" --schema-format human --entities "$folder/$entities" --request-json "$file" -v && printf '\0') | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we missing a case where -z "$schema"
but not -z "$links"
? just doesn't come up in the current tests?
Might be clearer (and less duplication) to define something like $schema_arg
to be either --schema "$folder/$schema" --schema-format human
or empty, and likewise $links_arg
, and then we can have the command just once and reference $schema_arg
and $links_arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we missing a case
No because that situation cannot happen: Args come in by order with schema first, links second. So if links is there, then schema must be too.
These are bash functions so I don't know how to make the args by name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, seems good.
I don't know how to make the args by name
I was meaning something like
if [ -z "$schema" ] then schema_arg='' else schema_arg='--schema "$folder/$schema" --schema-format human' fi
if [-z "$links" ] then links_arg='' else links_arg='-k "$folder/$links"' fi
IFS=$'\n' read -r -d '' -a tmp_array < <(cedar authorize ... $schema_arg $links_arg ... -v && printf '\0')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I have stacked commits with other PRs, so I'll fix it after all those are in.
Description of changes: Allow the test scripts to take a links file for template-linked policies