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

Bind stdin from users' interactive #296

Closed
atsushi-ishibashi opened this issue Nov 20, 2022 · 9 comments
Closed

Bind stdin from users' interactive #296

atsushi-ishibashi opened this issue Nov 20, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@atsushi-ishibashi
Copy link
Contributor

For example, email verification code step or MFA step.
book design image. Wait for users' stdin input at stdin runner step.

desc: Exec test
steps:
  -
    stdin:
      comment: 'Get MFA code: '
      (optional)timeout:
  -
    req:
      /hoge/{{ steps[0].stdin.value }}

If exec can solve what I want, please let me know!

When we have the concensus, I'll contribute👍

@k1LoW
Copy link
Owner

k1LoW commented Nov 20, 2022

Thank you for your request!

I have 3 questions

  1. Is the feature you want to input values from outside the runbook?
  2. For example, can't it be entered by an environment variable?
  3. Is there a reason you would like to enter it in the middle of the steps run?
    • For example, would entering all the values at the beginning of a runbook run satisfy your requirement?

@atsushi-ishibashi
Copy link
Contributor Author

Is the feature you want to input values from outside the runbook?

yes.

For example, can't it be entered by an environment variable?

yes.

Is there a reason you would like to enter it in the middle of the steps run?

yes.
Considering email verification or MFA senario so those aren't determined when I run book.

Email verification

  1. Open signup page via cdp
  2. Input email and password
  3. Send email with verification code to real email address
  4. Input verification code into runbook

MFA

  1. Signin request via http
  2. Got one time password via login email or got OTP via MFA application(like google authenticator)
  3. Input the code into runbook

@k1LoW
Copy link
Owner

k1LoW commented Nov 20, 2022

Thank you.

The MFA can be automated by emulating OTP (but only for go test code using Func).
Email Verification seems to be difficult indeed.

I'm wondering how to implement this.

@k1LoW
Copy link
Owner

k1LoW commented Nov 20, 2022

How about implementing it with a built-in function?

@k1LoW
Copy link
Owner

k1LoW commented Nov 20, 2022

How about an implementation like this?

@atsushi-ishibashi
Copy link
Contributor Author

At first, I consider whether it can be realized with existing features like built-in func👌

@atsushi-ishibashi
Copy link
Contributor Author

Thank you for your quick implementation. I'll check it later

@atsushi-ishibashi
Copy link
Contributor Author

Looks good!
What I want seems to be realized with #297 . thanks

@atsushi-ishibashi
Copy link
Contributor Author

works well. thanks!

desc: prompt
runners:
  req: https://example.com
vars:
  id: hoge
steps:
  prompt0:
    bind:
      otp: input("Enter otp> ", "")
  prompt1:
    bind:
      password: secret("Enter pass> ")
  prompt2:
    bind:
      choice: select("Choose > ", ["one", "two"], "")
  fuga:
    desc: fuga
    req:
      /?otp={{ otp }}&password={{ password }}&choice={{ choice }}:
        get:
          body:
            application/json: null

// output
Run 'bind' on 'prompt'.steps.prompt0
Enter otp> : hoge

Run 'bind' on 'prompt'.steps.prompt1
Enter pass> : 

Run 'bind' on 'prompt'.steps.prompt2
Choose >  (one/two): two

Run 'req' on 'prompt'.steps.fuga
-----START HTTP REQUEST-----
GET /?choice=two&otp=hoge&password=pass HTTP/1.1
Host: example.com
Content-Type: application/json

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

No branches or pull requests

2 participants