Last active
January 11, 2021 05:49
-
-
Save danielplawgo/b7f647af83d1345e9bac532cc10c8cfb to your computer and use it in GitHub Desktop.
Karate - automatyczne testy API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Auth - fetching jwt token | |
Background: | |
* url baseUrl+"/api/Auth/Login" | |
Scenario: Featch jwt token | |
Given request {"Username":"#(userName)","Password":"#(password)"} | |
When method POST | |
Then status 200 | |
And match response contains { "message": "Success" } | |
* def token = response.token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java -jar karate.jar -t ~@ignore src |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"baseUrl": "http://localhost:49705", | |
"userName": "[email protected]", | |
"password": "Password9." | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scenario: Login | |
Given url "run.cmd" | |
And request {"Username":"userName","Password":"password"} | |
When method POST | |
Then status 200 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Get product | |
Background: | |
* url baseUrl+'/api/products/1' | |
Scenario: Get product with id equal 1 | |
When method GET | |
Then status 200 | |
And match response == {"id":1,"name":"Name-1"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function() { | |
var config = karate.read('classpath:environment-config.json'); | |
var authResult = karate.callSingle('classpath:src/Auth.feature',config); | |
karate.configure('headers', { | |
'Authorization': 'Bearer ' + authResult.token | |
}); | |
return config; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -L https://github.com/intuit/karate/releases/download/v0.9.6/karate-0.9.6.jar --output karate.jar | |
java -jar karate.jar -t ~@ignore src |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment