Follow

Creating a New API Model

Starting a New Functional API Test

The first step in creating functional API Tests is to create an API model in API Test Maker that you use to generate the tests.

Once you are logged in to BlazeMeter, click Create Test at the top of the navigation bar, and then click API Test Maker. Be sure to create the test in the relevant Project.

Screen_Shot_2017_06_04_at_6.41.37_PM.png

APITestMaker.png

Clicking API Test Maker opens a new tab and displays the choices of Swagger and Manual. If you don't see it yet, click Create API Tests in the top navigation bar.

CreateAPITests.png

Importing a Swagger Specification

You can upload any valid API specification in either a .json or .yaml format to use as the basis of your API tests. The file size for each upload is limited to 1MB.

Note: There is a known issue where leaving your browser inactive for an extended period of time can, in rare instances, prevent the successful upload of a Swagger specification. If you are having an issue uploading a Swagger spec, try either clearing your browser cache or switching your browser to incognito mode.

  1. Click Create API Tests in the menu bar at the top of the page.
    The Create API Tests page opens.
  2. Drag the file that you want to upload into the Swagger area. You can also click this area to browse for files in a specific location.
    Your file displays in the Swagger section of the page.
  3. Click Generate Tests.
    The Edit API Tests page opens. This page shows the API model that was created, based on the uploaded specification. Tests are automatically created for each operation. This page defaults to the Tests tab where you can review the generated tests for a selected operation. A status bar at the top of the test tab shows the progress of the test generation for each operation.

Within the model, you can view and modify each of the resources and operations in your model. Select the operation in the left panel to view the details for that operation and make any desired changes.

After you make changes, you can regenerate the tests for a specific operation by clicking Generate Tests in the Tests tab. You can also regenerate all tests for all of the operations in your model by clicking Generate All Tests in the left panel.

To execute the tests for a specific operation, select the operation in the list of operations in the left panel. Click Execute Tests in the Tests tab for the selected operation.

For more information about modifying your API model, see Modifying the API Test Maker Model. For more information about generating tests, see Creating New Functional API Tests.

SwaggerModel2.png

The following video provides a brief introduction to importing a Swagger specification.

Creating an API Model Manually

If you don't have an existing specification for your API, you can also create a model by manually defining each of the resources and operations in your API.

  1. Click Create API Tests in the menu bar at the top of the page.
    The Create API Tests page opens.
  2. Click the Manual area.
    The Create Manual API Model window opens.
    ManualModel01.png
  3. Enter a base URL (without paths) and model name in the Base URL and Model Name fields.
  4. Click Next.
    The Edit API Tests page opens. Your base URL displays at the top of the page.
  5. Select the type of operation that you want to add (GET, POST, PUT, DELETE, or PATCH) at the bottom of the left panel.
    ManualModel02.png
  6. Type the resource path in the Enter resource path field.
    • Path parameters are defined as part of your resource path. They are indicated with {}. You can change reference values and constraints for path parameters in the Parameters tab, but you cannot add or remove them. By default, path parameters are created with a type of String, and the Required constraint is set to True.
      For example, /pet/{petId} creates a path parameter of petId.
    • Rather than creating query parameters one at a time in the Parameters tab, you can include them here in your resource path.
      For example, /user/login?username=admin&password=password creates a resource of /user/login with two query parameters: username with a reference value of admin, and password with a reference value of password.
    • The base URL displays at the top of the left pane. You do not need to repeat the base URL. Just enter the relative path. For example, type /pet instead of typing http://petstore.jsonpetstore.swagger.io/pet.
  7. Click the plus (+) sign to add a new resource to the resource list with the selected operation.
  8. Continue to add more operations and resource paths until your model is completely defined.
    You can only have one operation of each type (GET, POST, PUT, and so on) for each resource path. If the resource path that you enter already exists for the selected operation, an error message appears.
  9. (Optional) On the Summary tab, enter a description for the operation.
    This description displays in the list of models in the Manage API Tests page to help you identify it.

For more information about adding additional elements to an operation, such as parameters, reference values, and constraints, see Modifying the API Test Maker Model. For more information about generating tests from your model, see Creating New Functional API Tests.

The following video provides a brief introduction to manually creating an API model. 

Configuring Your Model

Most of the parameters and assertions that define your API tests are created at the operation level. But the following elements are defined at a model level, and are then applied to every test that you generate. You can define these elements from the fields at the top of the Edit API Tests page.

  • Test Execution Location
    You can use the default location for executing your tests, or you can select a specific execution location. This includes predefined geographic locations as well as any Private Locations that you defined in BlazeMeter to test applications behind a firewall. If you don't select a location, BlazeMeter automatically selects a default location for you at the time of execution. For more information about setting up on-premise testing for a private location, see Private Locations and Install a New On-Premise Agent.
  • API Key
    If you are testing an API that requires an API key, you can define your API key and then apply it to all of the tests that are generated for a specific model. For more information, see Managing Authentication in API Test Maker.
  • Authentication
    If you are testing an API that requires Basic Auth or OAuth credentials, you can define those credentials and then apply them to all of the tests that are generated for a specific model. For more information, see Managing Authentication in API Test Maker.
  • SQL Injection
    SQL injection tests check your API for vulnerability from SQL injection attacks where a partial or complete SQL query is injected along with an API request. For more information about creating this type of test, see Creating SQL Injection Tests

Note: Changes to Basic Auth, OAuth, and API Keys that are located in the request header are applied to your tests at the time of execution. If you make changes to any of these elements in your model, those changes are automatically applied to your tests the next time that you execute them. Changes to Test Execution Location, SQL Injection, or API Keys that are located in the query are applied to your tests at the time of test generation. If you make changes to these values, you must regenerate your tests to have these changes applied.

ModelConfig.png

Have more questions? Submit a request

0 Comments

Article is closed for comments.