Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Postman to stREST #88

Open
jgroom33 opened this issue Oct 25, 2018 · 4 comments
Open

Postman to stREST #88

jgroom33 opened this issue Oct 25, 2018 · 4 comments

Comments

@jgroom33
Copy link
Collaborator

jgroom33 commented Oct 25, 2018

strest foo.postman.json --postman

This would convert a postman collection into a set of directories and files.

There's no reasonable way to convert all the functionality (javascripts) so this should focus on creating the requests only.

@jgroom33
Copy link
Collaborator Author

jgroom33 commented Oct 26, 2018

@eykrehbein
help on this would be appreciated: https://github.com/eykrehbein/strest/blob/feature/postman_import/src/postman.ts#L80

to test:
node dist/main.js tests/postman/Postman\ Import.postman_collection.json -m

  • handle {{foo}} as hostname
  • convert pm.response.to.have.status(200) to validates @eykrehbein
  • convert pm.response.to.have.jsonBody('args.foo1', 'bar1') to validate @eykrehbein
  • convert pm.response.to.have.body(raw body) to validate @eykrehbein
  • handle headers
  • use url.(protocol, host, path) instead of url.raw
  • convert query params (instead of using url.raw)
  • create directories and files

@eykrehbein
Copy link
Owner

I'm on it 👍 @jgroom33

@eykrehbein
Copy link
Owner

@jgroom33 is the param of .to.have.jsonBody an object?

@jgroom33
Copy link
Collaborator Author

Looks like the .to.have.jsonBody can test whether the param exists and whether it is equal to a value.
I'm assuming we could only currently support:

validate:
  jsonpath:
    args.foo2: bar2

curl https://postman-echo.com/get?foo1=bar1&foo2=bar2
returns:

{
    "args": {
        "foo1": "bar1",
        "foo2": "bar2"
    },
    "headers": {
        "x-forwarded-proto": "https",
        "host": "postman-echo.com",
        "accept": "*/*",
        "accept-encoding": "gzip, deflate",
        "cookie": "sails.sid=s%3ApXoOiKY5-aoRZBuqlwdN0MJ2krjLjx21.c8qegiylITH2DQ9vyj%2BFMe74GEDtC%2BVmi1Y1TxO4fDQ",
        "user-agent": "PostmanRuntime/7.3.0",
        "x-forwarded-port": "443"
    },
    "url": "https://postman-echo.com/get?foo1=bar1&foo2=bar2"
}

tests:

pm.test("response body has json with request queries", function () {
    pm.response.to.have.jsonBody('args')
        .and.have.jsonBody('args.foo2', 'bar2')
    pm.response.to.have.jsonBody('args.foo1', 'bar1');
    pm.response.to.have.jsonBody('headers')
});

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

No branches or pull requests

2 participants