You're viewing legacy documentation for API Fortress (deployed via an on-premises container). To view documentation for the new SaaS version of API Fortress — now known as Sauce Labs API Testing and Monitoring (with Sauce Connect tunnels) — see API Testing on the Sauce Labs Cloud.
The vault allows you to store variables and code snippets that can be used across an entire project.
The link to access the Vault is at the top of the window, as shown below:
The first column shows all of the projects of a company and the Global Vault. Code snippets and variables saved in a specific project are only available in that project. They are not available across projects. If a variable and/or code snippet needs to be available in more projects within the company, they must be saved to the Global Vault.
The Global Vault has been built to make variables and code snippets available across all of the projects in a company.
In the snippet section, you will find all of the snippets you have created using the Composer (see here for more details).
Once you have saved the snippet, from the composer, you can choose whether you want to save it and make it available only for the current project or for all the projects within the company by saving it in the Global Vault. If you already have a snippet saved for the current project but you need to make it available across all projects, you can easily export them from the current project to the Global Vault by using the import/export feature.
A good use case for the snippets feature is an authentication flow; you don't need or want to rewrite all of the steps in every test. You just need to call the snippet that contains the authentication snippet. Another good example is integration testing, where you can reuse various tests to create one larger flow.
In the variable section, you can define variables that will be part of the scope of the tests.
If a variable with the same name is defined within the test, it will override the one defined in the Vault. For identical variable names in the global vault and in the project vault, the latter will have higher priority.
Defining a variable in the Vault is helpful when you need to use the same variable across multiple tests. This way, you don't need to rewrite it every time.
For example, a password could be saved as a variable and reused in multiple places.
Just like code snippets, if you need a variable available across multiple projects, you can save it in the Global Vault or import it directly from another project.
Additionally, you can import variables from Postman. See here for more details.
Vault Tab in Composer
When you open the Vault tab in the Composer, global snippets and variables will be highlighted for ease of identification.
Here is a quick example on how the Vault can be used in a test.
The Authentication Snippet
First, create a new test. Go to the test list, click +New Test, enter the test name and click Compose. Once the composer appears, simply enter the call. For this example, we will add a GET request that logs in using a Basic authentication:
Consider a scenario where this login will be required for all the endpoints we have to test. It makes sense for this call to be stored in the Vault.
GET, open the Vault panel and click the + button. Enter a name and description.
Now you can proceed with creating the test. Once done, you may create other tests for your API. Once again, click +New Test. Once you are in the Composer, you can open the Vault panel and select the snippet saved in the previous step.
To use the login call in the new test, just click the down arrow button next to the snippet, and it will be added into the test.
Now you can call the endpoint that you want to test. Let’s use the search endpoint. Pass the ”ID” variable as a query parameter. The authorization token that was parameterized after the login call will be passed in as well:
Now, consider the case where we want to use the same ”ID” in multiple tests. Don’t set the ID as a global param or an input set. Add it to the vault instead. Save the test and exit from the Composer. Click on Vault in the header and add the variable ”ID” here:
Once done, go back to the test and check that the variable is available in the Vault panel:
If you launch the test, you can see that the ”ID” will be replaced with the value you have set in the Vault.