@suffolklitlab/alkiln 5.12.0-delete3 → 5.12.0-delete4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,18 +43,22 @@ jobs:
43
43
  #### Developer note: You can probably leave out these specific
44
44
  #### environment variables. You may not even need the `env`
45
45
  #### keyword or values at all. See
46
- #### https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing#env-vars
46
+ #### https://assemblyline.suffolklitlab.org/docs/alkiln/writing#env-vars
47
47
  env:
48
48
  SECRET_VAR1: secret-var1-value
49
49
  SECRET_VAR2: secret-var2-value
50
50
  SECRET_FOR_MISSING_FIELD: secret for missing field
51
+ INVALID_API_KEY: invalidAPIkey
52
+ EMPTY_STRING: ""
53
+ USER_NO_PERMISSIONS_EMAIL: alkiln@example.com
54
+ USER_NO_PERMISSIONS_PASSWORD: User123^
51
55
 
52
56
  steps:
53
57
  # Place the root directory in this branch to access
54
58
  # relative paths to action files
55
59
  - uses: actions/checkout@v4
56
60
 
57
- - name: ALKiln - Start the isolated temporary docassemble server on GitHub
61
+ - name: "ALKiln - Start the isolated temporary docassemble server on GitHub"
58
62
  id: github_server
59
63
  #### Developer note: you'll need to replace `uses: ./action_for_github_server`
60
64
  #### with the path to ALKiln’s repository name and branch name. For example,
@@ -71,21 +75,53 @@ jobs:
71
75
  shell: bash
72
76
 
73
77
  #### Developer note: You can probably leave this out
74
- # # Optional debugging to explore things like docker issues
75
- # - name: Docker debug tmate session
76
- # if: ${{ failure() && github.event.inputs.enable_tmate == 'true' }}
77
- # uses: mxschmitt/action-tmate@v3
78
+ - name: "Create a new normal user with an API key env var"
79
+ env:
80
+ SERVER_URL: "${{ steps.github_server.outputs.SERVER_URL }}"
81
+ KEY: ${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}
82
+ run: |
83
+ # Create user and their API key
84
+ sudo apt-get install jq
85
+
86
+ # https://docassemble.org/docs/api.html#user_new
87
+ user_data=$(curl -X POST \
88
+ ${{ env.SERVER_URL }}/api/user/new \
89
+ -H 'Content-Type: application/json' \
90
+ -d '{
91
+ "key": "${{ env.KEY }}",
92
+ "username": "${{ env.USER_NO_PERMISSIONS_EMAIL }}",
93
+ "password": "${{ env.USER_NO_PERMISSIONS_PASSWORD }}"
94
+ }')
95
+ echo "User data:"
96
+ echo "$user_data"
97
+
98
+ user_id=$(echo "$user_data" | jq '.user_id' -r)
99
+
100
+ # https://docassemble.org/docs/api.html#api_user_user_id_api_post
101
+ new_key=$(curl -X POST \
102
+ ${{ env.SERVER_URL }}/api/user/"$user_id"/api \
103
+ -H 'Content-Type: application/json' \
104
+ -d '{
105
+ "key": "${{ env.KEY }}",
106
+ "name": "alkiln_key",
107
+ "method": "none"
108
+ }')
109
+ echo "User new key:"
110
+ echo "$new_key"
111
+
112
+ echo "USER_NO_PERMISSIONS_API_KEY=$new_key" >> "$GITHUB_ENV"
113
+
114
+ ### Developer note: You can probably leave this out
115
+ # Optional debugging to explore things like docker issues
116
+ - name: Docker debug tmate session
117
+ #if: ${{ failure() && github.event.inputs.enable_tmate == 'true' }}
118
+ uses: mxschmitt/action-tmate@v3
78
119
 
79
120
  #### Developer note: You can probably leave this out
80
- - name: Run ALKiln - Env vars for our own tests from server output
121
+ - name: "Create other env vars for our own tests from server output"
81
122
  run: |
82
123
  echo "USER1_EMAIL=${{ steps.github_server.outputs.DA_ADMIN_EMAIL }}" >> $GITHUB_ENV
83
124
  echo "USER1_PASSWORD=${{ steps.github_server.outputs.DA_ADMIN_PASSWORD }}" >> $GITHUB_ENV
84
- echo "USER_NO_PERMISSIONS_EMAIL=${{ steps.github_server.outputs.DA_ADMIN_EMAIL }}" >> $GITHUB_ENV
85
- echo "USER_NO_PERMISSIONS_PASSWORD=${{ steps.github_server.outputs.DA_ADMIN_PASSWORD }}" >> $GITHUB_ENV
86
- echo "USER_NO_PERMISSIONS_API_KEY=${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}" >> $GITHUB_ENV
87
- echo "INVALID_API_KEY=invalidAPIkey" >> $GITHUB_ENV
88
- echo "EMPTY_STRING=''" >> $GITHUB_ENV
89
125
 
90
126
  #### Developer note:
91
127
  #### Example of working with the docker container after it's been
@@ -111,12 +147,12 @@ jobs:
111
147
  ALKILN_TAG_EXPRESSION: "${{ (github.event.inputs.tags && format('{0}', github.event.inputs.tags)) || '(not @error) and (not @temp_error)' }}"
112
148
  with:
113
149
  #### Developer note: Required inputs. See
114
- #### https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing/#sandbox-inputs
150
+ #### https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#sandbox-inputs
115
151
  SERVER_URL: "${{ steps.github_server.outputs.SERVER_URL }}"
116
152
  DOCASSEMBLE_DEVELOPER_API_KEY: "${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}"
117
153
  INSTALL_METHOD: "server"
118
154
  #### Developer note: You can probably leave the rest out
119
- #### To learn more, see https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing/#optional-inputs
155
+ #### To learn more, see https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#optional-inputs
120
156
  ALKILN_TAG_EXPRESSION: "${{ env.ALKILN_TAG_EXPRESSION }}"
121
157
  ALKILN_VERSION: delete
122
158
 
@@ -24,4 +24,6 @@ jobs:
24
24
  with:
25
25
  node-version: ${{ matrix.node-version }}
26
26
  - run: npm install
27
+ - name: Docker debug tmate session
28
+ uses: mxschmitt/action-tmate@v3
27
29
  - run: npm run codes
@@ -69,10 +69,10 @@ jobs:
69
69
  ALKILN_TAG_EXPRESSION: "${{ (github.event.inputs.tags && format('{0}', github.event.inputs.tags)) || '(not @error) and (not @temp_error)' }}"
70
70
  with:
71
71
  #### Developer note: Required ALKiln inputs. You can read more at
72
- #### https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing/#githubNyou-inputs
72
+ #### https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#githubNyou-inputs
73
73
  SERVER_URL: "${{ env.SERVER_URL }}"
74
74
  DOCASSEMBLE_DEVELOPER_API_KEY: "${{ env.DOCASSEMBLE_DEVELOPER_API_KEY }}"
75
- #### Developer note: See https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing/#optional-inputs
75
+ #### Developer note: See https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#optional-inputs
76
76
  #### You can probably leave this out
77
77
  # Internal: docassemble changes sometimes break @a11y tests. That is
78
78
  # a da problem, not ours. We will trigger these tests manually when we
@@ -232,7 +232,7 @@ da_i.get_api_key_access_status = async function ({ timeout = null, api_key = nul
232
232
  } // ends try
233
233
  } // ends auth_data.codes only has the first code
234
234
 
235
- log.debug({ type: `da api info`, code: `ALK0202`,
235
+ log.info({ type: `da api info`, code: `ALK0202`,
236
236
  pre: `API key authentication info`, data: auth_data });
237
237
 
238
238
  return auth_data;
@@ -292,7 +292,7 @@ da_i.quietly_delete_one_interview = async function ( timeout, { interview = {},
292
292
  /** Try to delete an interview using all available API keys. Fail silently.
293
293
  * Example failure: the test did not log in any users and the testing
294
294
  * account's role prevents access to other user's interviews. */
295
- api_keys = normalize_api_keys( api_keys );
295
+
296
296
  let responses = [];
297
297
  for ( let api_key of api_keys ) {
298
298
  try {
@@ -324,8 +324,6 @@ da_i.get_interviews = async function ({ interviews = {}, api_keys = [], options
324
324
  /** Return an object of interviews that exist on the server
325
325
  * that match the given interviews. Keys are the session ids. */
326
326
 
327
- api_keys = normalize_api_keys( api_keys );
328
-
329
327
  let fetched_interviews = {};
330
328
  if ( interviews ) {
331
329
  for ( let id in interviews ) {
@@ -346,7 +344,6 @@ da_i.get_interview = async function ({ interview = {}, api_keys = [], options =
346
344
 
347
345
  // Defaults
348
346
  let { timeout } = options || { timeout: DEFAULT_MAX_REQUEST_MS };
349
- api_keys = normalize_api_keys( api_keys );
350
347
 
351
348
  if ( interview && interview.uid ) {
352
349
  for ( let api_key of api_keys ) {
@@ -379,11 +376,3 @@ da_i.get_interview = async function ({ interview = {}, api_keys = [], options =
379
376
  return null;
380
377
 
381
378
  }; // Ends da_i.get_interview()
382
-
383
- let normalize_api_keys = function ( api_keys = [] ) {
384
- /** Ensure the dev API key is in the api_keys list. */
385
- let dev_key = session_vars.get_dev_api_key();
386
- if ( !api_keys ) { api_keys = [ dev_key ]; }
387
- if ( !api_keys.includes( dev_key ) ) { api_keys.unshift( dev_key ); }
388
- return api_keys;
389
- };
package/lib/scope.js CHANGED
@@ -2996,17 +2996,17 @@ module.exports = {
2996
2996
  // Save API key to clean up interviews later. Nice to have, not critical
2997
2997
  if ( api_key_secret_name ) {
2998
2998
  let api_key = process.env[ api_key_secret_name ];
2999
- let api_key_msg = `The API key called "${ api_key_secret_name }" is missing. Check for a typo in your test, workflow file, GitHub secret, or server config.`
2999
+ let api_key_msg = `The API key in the variable "${ api_key_secret_name }" is missing. Check for a typo in your test, workflow file, GitHub secret, or server config.`
3000
3000
  if ( api_key === undefined ) {
3001
3001
  reports.addToReport( scope, { type: `warning`, code: `ALK0199`, value: api_key_msg });
3002
3002
  } else if ( api_key === `` ) {
3003
3003
  reports.addToReport( scope, { type: `warning`, code: `ALK0200`,
3004
- value: `ALKiln found the API key called "${ api_key_secret_name }", but it was empty. It had no text in it. Edit the value of the GitHub secret or server config variable called "${ api_key_secret_name }".` });
3004
+ value: `ALKiln found the API key in the variable "${ api_key_secret_name }", but it was empty. It had no text in it. Edit the value of the GitHub secret or server config variable called "${ api_key_secret_name }".` });
3005
3005
  } else {
3006
3006
  let access_info = await da_api.get_api_key_access_status({ api_key });
3007
3007
  if ( !access_info.has_auth ) {
3008
3008
  reports.addToReport( scope, { type: `warning`, code: `ALK0201`,
3009
- value: `The server rejected the API key called "${ api_key_secret_name }". Does it exist on this server? Was it deleted somehow? You can always make a new one.` });
3009
+ value: `The server rejected the API key in the variable "${ api_key_secret_name }". Does it exist on this server? Was it deleted somehow? You can always make a new one.` });
3010
3010
  }
3011
3011
  // Even if it doesn't have access, give it a shot anyway.
3012
3012
  // Maybe we got something wrong.
package/lib/steps.js CHANGED
@@ -140,7 +140,7 @@ Before(async (scenario) => {
140
140
  scope.scenario_id = uuidv4();
141
141
  scope.scenarios.set( scope.scenario_id, {} );
142
142
  scope.scenarios.get( scope.scenario_id ).interviews = {};
143
- scope.scenarios.get( scope.scenario_id ).api_keys = [ session_vars.get_dev_api_key() ];
143
+ scope.scenarios.get( scope.scenario_id ).api_keys = [];
144
144
  scope.expected_status = null;
145
145
  scope.expected_in_report = null;
146
146
  scope.expected_not_in_report = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "5.12.0-delete3",
3
+ "version": "5.12.0-delete4",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {