-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84195e8
commit 661028e
Showing
9 changed files
with
119 additions
and
49 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,49 @@ | ||
# Testes de API com REST-assured e JUnit 5. | ||
|
||
## Pré-requisitos de ambiente 📋 💻 | ||
## Pré-requisitos mínimos de ambiente: | ||
|
||
[Java](https://www.oracle.com/br/java/technologies/downloads/#java11) 11.0.20. | ||
* [Java](https://www.oracle.com/br/java/technologies/downloads/#java11) 11.0.x. | ||
|
||
## Execução dos testes pelo CMD ✅ ✅ | ||
## IDE de desenvolvimento: | ||
|
||
* [Eclipse](https://eclipseide.org). | ||
|
||
## Clone do repositório: | ||
|
||
``` | ||
git clone https://github.com/thinogueiras/REST-assured.git | ||
``` | ||
|
||
## Abrir o projeto no Eclipse: | ||
|
||
* Abra o Eclipse >> Menu File >> Import >> Maven >> Existing Maven Projects. | ||
* Navegar até o repositório clonado >> Selecionar a pasta >> Finish. | ||
|
||
## Execução dos testes: | ||
|
||
### JUnit: | ||
|
||
* Após importar o projeto com sucesso no Eclipse, clique para expandir o Source Folder: `src/test/java`, clique com o botão `direito` do mouse sobre o package: `br.qa.thinogueiras.suite` >> Run As >> JUnit Test. | ||
|
||
### Terminal: | ||
|
||
``` | ||
mvn clean test | ||
``` | ||
|
||
## Relatório da execução 📝 📄 | ||
## Relatório: | ||
* #### Abrir o terminal e digitar: | ||
|
||
``` | ||
allure serve allure-results | ||
``` | ||
``` | ||
allure serve allure-results | ||
``` | ||
|
||
![Alt text](/images/allure-report.png) | ||
![Alt text](/.github/images/allure-results.png) | ||
|
||
--- | ||
|
||
<a href="https://www.linkedin.com/in/thinogueiras"><img alt="Linkedin" src="https://img.shields.io/badge/-LinkedIn-blue?style=for-the-badge&logo=Linkedin&logoColor=white"></a> | ||
|
||
<strong>Thiago Nogueira dos Santos</strong> 🤓 🫰🏽 | ||
<strong>Thiago Nogueira dos Santos</strong> 🤓 ✌🏻 | ||
|
||
QA Automation Engineer 🔎 🐞 |
Binary file not shown.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package br.qa.thinogueiras.core; | ||
|
||
import static br.qa.thinogueiras.utils.Utils.resetUserData; | ||
import static io.restassured.RestAssured.given; | ||
import static io.restassured.RestAssured.requestSpecification; | ||
|
||
|
@@ -11,24 +12,10 @@ | |
|
||
public class TokenFactory { | ||
|
||
private static String TOKEN; | ||
private static String TOKEN = ""; | ||
private static RequestSpecification HEADER; | ||
private static FilterableRequestSpecification request; | ||
|
||
public static String getToken() { | ||
if(TOKEN == null || HEADER == null) { | ||
generateToken(); | ||
} | ||
|
||
return TOKEN; | ||
} | ||
|
||
public static void removeAuthorization() { | ||
request = (FilterableRequestSpecification) requestSpecification; | ||
request.removeHeader("Authorization"); | ||
HEADER = null; | ||
} | ||
|
||
private static void generateToken() { | ||
Map<String, String> login = new HashMap<>(); | ||
login.put("email", "[email protected]"); | ||
|
@@ -45,4 +32,20 @@ private static void generateToken() { | |
|
||
HEADER = requestSpecification.header("Authorization", "JWT " + TOKEN); | ||
} | ||
|
||
public static String getToken() { | ||
if(HEADER == null) { | ||
generateToken(); | ||
|
||
resetUserData();; | ||
} | ||
|
||
return TOKEN; | ||
} | ||
|
||
public static void removeAuthorization() { | ||
request = (FilterableRequestSpecification) requestSpecification; | ||
request.removeHeader("Authorization"); | ||
HEADER = null; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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