v1 API testing with Postman
Postman is a popular tool for testing APIs. Postman collections and environments are available in
tests/postman for testing the functionality of the v1 API. This is particularly useful for those updating old, or creating new WaterButler providers. Follow the link for instructions on installing the Postman App or its commandline counterpart Newman.
Quickstart for Newman:
npm install -g newman
newman run tests/postman/collections/copy_files.json -e copy_file_sample.json
Specific collection instructions
- Create two projects in OSF. Take note of their IDs. You will need the IDs for the Postman environment file.
- Setup the provider you wish to test, in each of the two OSF projects. Provider root must be the same in both OSF projects.
- (Optional) If you wish to use a provider, other then osfstorage, for testing inter provider copies, setup an alternative provider in each of the two OSF projects
- Make a copy of
tests/postman/environments/copy_file_sample.jsonand edit as follows.
PID2values with your two project IDs.
providervalue with the name of the provider you wish to test.
alt_providervalue with the name of the provider you will use for inter provider copy testing.
basic_authvalue with the basic auth token representing your login to OSF. This can be found using the Postman App. Open a new request, click on authorization tab, select Basic Auth in Type dropdown. Enter your login and password. Click Update Request. Click on Headers Tab. Take note of the value of Authorization header. The value you are looking for is the rest of the string after “Basic “.
portcan be left as is assuming you have set up your dev environment in the default manner.
- Import the collection you would like to run from
tests/postman/collectionsand the environment file you just updated into the Postman App.
- Note: Importing your environment may give a few errors. It is most likely fine and should still run.
- Run the imported collections using the imported environment.
- Note: A failed run may leave files and/or folders behind. You will need to manually remove these before starting another run.