Categories: Uncategorized

by Jerome Josephraj

Share

REST uses four Authentication mechanisms and one of the popular authentication mechanisms is “Token Authentication” or “Bearer Authentication”. As the name “Bearer Authentication” suggests this type of authentication gives access to the bearer of this token. The token is a cryptic number and generated by the server in response to a login request. The client uses this token in the header of subsequent API calls in order to access protected APIs.

In this blog, let’s look at a step by step example of how this dynamically generated Token can be generated and passed to another Step in your Feature using NoCodeBDD. Creating Feature, Scenarios, Steps and rolling out Behavior Driven Development and Automating using NoCodeBDD literally takes minutes and all can be done without writing any code. If you are new to NoCodeBDD, you can see one of our previous blog that shows how REST API testing can be automated in minutes without writing any code

Step 1: Create Token

In order to pass the Token, it has to be created first. This can be done by calling the login API as shown in the example below. Once the login API is called, you can see result of that in the Audit screen

Step 2: Pass Token using JSON Path

You can pass result of any previous steps to subsequent steps using JSON Path. For an example, in the API that is called in Step 1, the token value can be passed to any subsequent Steps in that Scenario by simply providing the JSON Path for that token. If you are not familiar with JSON Path, there are several online tools available such as JSONPathFinder. We have put together a tutorial on how to find JSON Path for any element. The tutorial is very handy to find any JSON Path.

As you can see, passing Token or any values from one BDD Step to another Step in NoCodeBDD is as easy as providing the JSON Path. As mentioned before the response from a Step, can be passed to any Steps within that Scenario. When a Step is executed, NoCodeBDD walks back all the previous steps response and pull the required element if a JSON Path is provided.

STAY IN THE LOOP

Subscribe to our free newsletter.

Related Posts

View all

  • Continue reading
  • With NoCodeBDD, teams can automate Behavior-Driven Development (BDD) Scenarios for mobile applications with few clicks. To create test automation for mobile scenarios, typically, one would use Appium. Using NoCodeBDD, all you have to do is: Following gif shows how this is done for a sample mobile application: NoCodeBDD Mobile Automation NoCodeBDD […]

    Continue reading
  • if("student".equals(userType)){ Assert.assertEquals("STUDENT REGISTERED SUCCESSFULLY",actualMsg); }else{ Assert.assertEquals("ALUMNI REGISTERED SUCCESSFULLY",actualMsg); } When you have test code written like that given above—or. in other words, the code is written to assert an outcome based on conditional logic—it won’t test the scenario as it should. When writing test automation code for behavior-driven development (BDD) […]

    Continue reading
  • There is a general mis-conception that BDD should be used for testing. Many projects consider using BDD during “Testing phase” and only the QA team uses BDD. When BDD is rolled out this way, the teams don’t see the benefits. In this short video, I have explained how Behavior Driven […]

    Continue reading