-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat(scripted-client): supporting passing templating variables and a top level filter #107
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dab34c5
feat(scripted-client): supporting passing templating variables and a …
sminez c2ebd39
feat(scripted-client): getting a working spread-style integration tes…
sminez d995a64
feat(scripted-client): outputing resolved sequence when a prompt sequ…
sminez efcf5ea
chore(scripted-client): updating docs
sminez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...pting-client/resources/prompt-sequence-tests/sequence_with_top_level_filter_and_vars.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"version": 1, | ||
"prompt-filter": { | ||
"snap": "aa-prompting-test", | ||
"interface": "home", | ||
"constraints": { | ||
"path": "$BASE_PATH/*" | ||
} | ||
}, | ||
"prompts": [ | ||
{ | ||
"prompt-filter": { | ||
"snap": "testSnap", | ||
"interface": "home", | ||
"constraints": { | ||
"path": "$BASE_PATH/bar", | ||
"requested-permissions": [ "read" ], | ||
"available-permissions": [ "read", "write", "execute" ] | ||
} | ||
}, | ||
"reply": { | ||
"action": "allow", | ||
"lifespan": "single", | ||
"constraints": { | ||
"path-pattern": "${BASE_PATH}/bar", | ||
"permissions": [ "read", "write" ] | ||
} | ||
} | ||
} | ||
] | ||
} |
28 changes: 28 additions & 0 deletions
28
prompting-client/resources/scripted-tests/happy-path-read/prompt-sequence.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"version": 1, | ||
"prompt-filter": { | ||
"snap": "aa-prompting-test", | ||
"interface": "home", | ||
"constraints": { | ||
"path": "$BASE_PATH/.*" | ||
} | ||
}, | ||
"prompts": [ | ||
{ | ||
"prompt-filter": { | ||
"constraints": { | ||
"path": ".*/test.txt", | ||
"requested-permissions": [ "read" ] | ||
} | ||
}, | ||
"reply": { | ||
"action": "allow", | ||
"lifespan": "single", | ||
"constraints": { | ||
"path-pattern": "${BASE_PATH}/test.txt", | ||
"permissions": [ "read" ] | ||
} | ||
} | ||
} | ||
] | ||
} |
31 changes: 31 additions & 0 deletions
31
prompting-client/resources/scripted-tests/happy-path-read/test.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env sh | ||
# A simple allow once test of a read prompt. | ||
# Running this test script requires that the accompanying prompt-sequence.json | ||
# file be present in the output directory. | ||
|
||
PREFIX="$1" | ||
TEST_DIR="/home/ubuntu/test/$PREFIX" | ||
|
||
prompting-client.scripted \ | ||
--script="$TEST_DIR/prompt-sequence.json" \ | ||
--var "BASE_PATH:$TEST_DIR" | tee "$TEST_DIR/outfile" & | ||
|
||
# Ensure that the test client is already listening | ||
sleep 0.2 | ||
TEST_OUTPUT="$(aa-prompting-test.read "$PREFIX")" | ||
|
||
# Ensure that the test client has time to write its output | ||
# For tests with a grace period this will need to be taken into account as well | ||
sleep 0.2 | ||
CLIENT_OUTPUT="$(cat "$TEST_DIR/outfile")" | ||
|
||
if [ "$CLIENT_OUTPUT" != "success" ]; then | ||
echo "test failed" | ||
echo "output='$CLIENT_OUTPUT'" | ||
exit 1 | ||
fi | ||
|
||
if [ "$TEST_OUTPUT" != "testing testing 1 2 3" ]; then | ||
echo "test script failed" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As discussed, it might be nice in the future to have an array of top level filters, and any prompt which matches any of the filters in the array is considered. But we don't need this yet.
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.
yup 🙂
As and when you come across a test case where you need this let me know and we can take a look at implementing it with that in mind 👍