Skip to content
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

Using token generated from config.yml in scenarios/file1.yml #2578

Open
sami-dig opened this issue Mar 14, 2024 · 0 comments
Open

Using token generated from config.yml in scenarios/file1.yml #2578

sami-dig opened this issue Mar 14, 2024 · 0 comments

Comments

@sami-dig
Copy link

sami-dig commented Mar 14, 2024

I have following directory structure

  • project

    • config.yml
    • credentials.csv
    • scenarios
      • downloadFile.yml
  • config file

config:
 plugins:
   expect: {}
   apdex: {}
   metrics-by-endpoint:
     useOnlyRequestName: true
 payload:
   # path is relative to the location of the test script
   path: "credential.csv"
   fields:
     - "email"
     - "password"
     - "clientUuid"
   order: "sequence"
   skipHeader: true
 headers:
   x-client-uuid: "{{ clientUuid }}"
 http:
   timeout: 10
   extendedMetrics: true
 environments:
   functional:
     target: "http://127.0.0.1:2600"
     phases:
       - duration: 1
         arrivalRate: 1
   load:
     target: "http://127.0.0.1:2600"
     phases:
       - duration: 600
         arrivalRate: 10

before:
   flow:
     - log: "Get auth token"
     - post:
         url: "/auth/login"
         json:
           email: "{{ email }}"
           password: "{{ passwords }}"
         capture:
           - json: $.token
             as: token
         expect:
           - statusCode: 200


after:
 flow:
   - log: "---------------------"
   - log: "Invalidate token"
   - log: "---------------------"
   - post:
       url: "/auth/logout"
       headers:
         Authorization: "Bearer {{ token }}"
       json:
         Authorization: "{{ token }}"
  • downloadFile file
scenarios:
  - flow:
      - get:
          url: "/files/83"
          headers:
            authorization: "Bearer {{ token }}"
            x-client-uuid: "{{ clientUuid }}"
          expect:
            - statusCode: 200

I am getting

Error: Failed capture or match
    at /Users/sami/.nvm/versions/node/v18.16.0/lib/node_modules/artillery/node_modules/@artilleryio/int-core/lib/engine_http.js:626:33
    at /Users/sami/.nvm/versions/node/v18.16.0/lib/node_modules/artillery/node_modules/async/dist/async.js:473:16
    at replenish (/Users/sami/.nvm/versions/node/v18.16.0/lib/node_modules/artillery/node_modules/async/dist/async.js:1009:25)
    at /Users/sami/.nvm/versions/node/v18.16.0/lib/node_modules/artillery/node_modules/async/dist/async.js:1019:9
    at eachLimit$1 (/Users/sami/.nvm/versions/node/v18.16.0/lib/node_modules/artillery/node_modules/async/dist/async.js:3199:24)
    at Object.<anonymous> (/Users/sami/.nvm/versions/node/v18.16.0/lib/node_modules/artillery/node_modules/async/dist/async.js:1049:16)
    at captured (/Users/sami/.nvm/versions/node/v18.16.0/lib/node_modules/artillery/node_modules/@artilleryio/int-core/lib/engine_http.js:593:21)
    at /Users/sami/.nvm/versions/node/v18.16.0/lib/node_modules/artillery/node_modules/@artilleryio/int-commons/engine_util.js:499:16
    at /Users/sami/.nvm/versions/node/v18.16.0/lib/node_modules/artillery/node_modules/async/dist/async.js:473:16
    at replenish (/Users/sami/.nvm/versions/node/v18.16.0/lib/node_modules/artillery/node_modules/async/dist/async.js:1009:25)

The aim is to use the token generated from config.yml into scenarios/downloadFile.yml but I don't know how. I have also tried using {{ config.token }} and it didn't work. Can anyone please help me with this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant