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

add secrets field to define credential variables #414

Merged
merged 5 commits into from
Apr 25, 2024
Merged

add secrets field to define credential variables #414

merged 5 commits into from
Apr 25, 2024

Conversation

zoncoen
Copy link
Owner

@zoncoen zoncoen commented Apr 18, 2024

The secrets field allows defining variables like the vars field. Besides, the values defined by the secrets field are masked in the outputs.

schemaVersion: scenario/v1
plugins:
  plugin: plugin.so
vars:
  clientId: abcdef
secrets:
  clientSecret: XXXXX
title: get user profile
steps:
- title: get access token
  protocol: http
  request:
    method: POST
    url: 'http://example.com/oauth/token'
    header:
      Content-Type: application/x-www-form-urlencoded
    body:
      grant_type: client_credentials
      client_id: '{{vars.clientId}}'
      client_secret: '{{secrets.clientSecret}}'
  expect:
    code: OK
    body:
      access_token: '{{$ != ""}}'
      token_type: Bearer
  bind:
    secrets:
      accessToken: '{{response.body.access_token}}'
- title: get user profile
  protocol: http
  request:
    method: GET
    url: 'http://example.com/users/zoncoen'
    header:
      Authorization: 'Bearer {{secrets.accessToken}}'
  expect:
    code: OK
    body:
      name: zoncoen
...
        --- PASS: scenarios/get-profile.yaml/get_user_profile/get_access_token (0.00s)
                request:
                  method: POST
                  url: http://example.com/oauth/token
                  header:
                    Content-Type:
                    - application/x-www-form-urlencoded
                  body:
                    client_id: abcdef
                    client_secret: {{secrets.clientSecret}}
                    grant_type: client_credentials
                response:
...
                  body:
                    access_token: {{secrets.accessToken}}
                    token_type: Bearer
                elapsed time: 0.001743 sec
        --- PASS: scenarios/get-profile.yaml/get_user_profile/get_user_profile (0.00s)
                request:
                  method: GET
                  url: http://example.com/users/zoncoen
                  header:
                    Authorization:
                    - Bearer {{secrets.accessToken}}
...

resolve #302

@zoncoen zoncoen force-pushed the secret branch 10 times, most recently from ac519f2 to e44b832 Compare April 24, 2024 19:10
@zoncoen zoncoen changed the title WIP: add secrets field to define credential variables add secrets field to define credential variables Apr 24, 2024
@zoncoen zoncoen merged commit 2ca90ab into main Apr 25, 2024
18 of 20 checks passed
@zoncoen zoncoen deleted the secret branch April 25, 2024 13:15
@zoncoen zoncoen added the enhancement New feature or request label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a secrets field to prevent showing credentials in logs
1 participant