Compare commits
No commits in common. "dev" and "main" have entirely different histories.
13 changed files with 2 additions and 502 deletions
41
.gitignore
vendored
41
.gitignore
vendored
|
|
@ -1,41 +0,0 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
/allure-results/
|
||||
.allure
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
# QA
|
||||
|
||||
145
pom.xml
145
pom.xml
|
|
@ -1,145 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>Test</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<aspectj.version>1.9.23</aspectj.version>
|
||||
<lombok.version>1.18.36</lombok.version>
|
||||
<rest.assured.version>5.5.1</rest.assured.version>
|
||||
<testng.version>7.10.2</testng.version>
|
||||
<allure.version>2.29.1</allure.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>io.qameta.allure</groupId>
|
||||
<artifactId>allure-maven</artifactId>
|
||||
<version>2.15.2</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<configuration>
|
||||
<argLine>
|
||||
-javaagent:"${settings.localRepository}"/org/aspectj/aspectjweaver/1.9.23/aspectjweaver-1.9.23.jar
|
||||
</argLine>
|
||||
<suiteXmlFiles>
|
||||
<suiteXmlFile>
|
||||
src/test/resources/suites/tests.xml
|
||||
</suiteXmlFile>
|
||||
</suiteXmlFiles>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.qameta.allure</groupId>
|
||||
<artifactId>allure-bom</artifactId>
|
||||
<version>${allure.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- TestNG -->
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>${testng.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Rest Assured -->
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>${rest.assured.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Allure -->
|
||||
<dependency>
|
||||
<groupId>io.qameta.allure</groupId>
|
||||
<artifactId>allure-testng</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.qameta.allure</groupId>
|
||||
<artifactId>allure-rest-assured</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON Processing -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.18.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- AspectJ -->
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>${aspectj.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Selenide -->
|
||||
<dependency>
|
||||
<groupId>com.codeborne</groupId>
|
||||
<artifactId>selenide</artifactId>
|
||||
<version>7.6.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Annotation Processor for Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>0.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
package endpoints;
|
||||
|
||||
import helpers.PropertyProvider;
|
||||
import io.qameta.allure.Step;
|
||||
import io.restassured.response.Response;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import pojo.UserRequest;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
|
||||
public class UserEndpoint {
|
||||
private static final String ENDPOINT = PropertyProvider.getProperty("endpoint.user");
|
||||
|
||||
@Step("Создание запроса о информации пользователя")
|
||||
public static UserRequest addUser() {
|
||||
return UserRequest.builder()
|
||||
.id(PropertyProvider.getProperty("test.id"))
|
||||
.username(PropertyProvider.getProperty("test.username"))
|
||||
.firstName(PropertyProvider.getProperty("test.firstname"))
|
||||
.lastName(PropertyProvider.getProperty("test.lastname"))
|
||||
.email(PropertyProvider.getProperty("test.email"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Step("Добавить информацию о пользователе и вернуть его ID")
|
||||
public static Response addUserId(RequestSpecification spec, UserRequest userRequest) {
|
||||
return given(spec)
|
||||
.body(userRequest)
|
||||
.when()
|
||||
.post(ENDPOINT)
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().response();
|
||||
}
|
||||
|
||||
@Step("Получить информацию о текущем пользователе")
|
||||
public static Response getUser(RequestSpecification spec) {
|
||||
return given(spec)
|
||||
.when()
|
||||
.get(ENDPOINT);
|
||||
}
|
||||
|
||||
@Step("Получить информацию о пользователе по ID: {userId}")
|
||||
public static Response getUserById(RequestSpecification spec, String userId) {
|
||||
return given(spec)
|
||||
.pathParam("id", userId)
|
||||
.when()
|
||||
.get(ENDPOINT + "/{id}");
|
||||
}
|
||||
|
||||
@Step("Обновить информацию о пользователе: {user}")
|
||||
public static Response updateUser(RequestSpecification spec, UserRequest userRequest) {
|
||||
return given(spec)
|
||||
.body(userRequest)
|
||||
.when()
|
||||
.put(ENDPOINT);
|
||||
}
|
||||
|
||||
@Step("Удалить текущего пользователя")
|
||||
public static Response deleteUser(RequestSpecification spec) {
|
||||
return given(spec)
|
||||
.when()
|
||||
.delete(ENDPOINT);
|
||||
}
|
||||
|
||||
@Step("Удалить пользователя по ID: {userId}")
|
||||
public static Response deleteUserById(RequestSpecification spec, String userId) {
|
||||
return given(spec)
|
||||
.pathParam("id", userId)
|
||||
.when()
|
||||
.delete(ENDPOINT + "/{id}");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
package helpers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class PropertyProvider {
|
||||
private static final Properties properties = new Properties();
|
||||
private static final String CONFIG_FILE = "config.properties";
|
||||
|
||||
static {
|
||||
try (InputStream input = PropertyProvider.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) {
|
||||
if (input == null) {
|
||||
throw new RuntimeException("Не найден файл конфигурации" + CONFIG_FILE);
|
||||
}
|
||||
properties.load(input);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Ошибка загрузки конфигурационного файла", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getProperty(String key) {
|
||||
return properties.getProperty(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package helpers;
|
||||
|
||||
import io.qameta.allure.restassured.AllureRestAssured;
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
import io.restassured.http.ContentType;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
|
||||
public class Specifications {
|
||||
protected static final String BASE_URL = PropertyProvider.getProperty("base.url");
|
||||
|
||||
public static RequestSpecification initRequestSpecification(String authToken) {
|
||||
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
|
||||
RequestSpecBuilder requestSpecBuilder = new RequestSpecBuilder();
|
||||
requestSpecBuilder
|
||||
.setBaseUri(BASE_URL)
|
||||
.setContentType(ContentType.JSON)
|
||||
.setAccept(ContentType.JSON)
|
||||
.addHeader("Authorization", "Bearer " + authToken)
|
||||
.addFilter(new AllureRestAssured());
|
||||
return requestSpecBuilder.build();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
package pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
|
||||
public class UserRequest {
|
||||
private String id;
|
||||
private String username;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String email;
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
package tests;
|
||||
|
||||
import endpoints.UserEndpoint;
|
||||
import helpers.PropertyProvider;
|
||||
import helpers.Specifications;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import org.testng.annotations.*;
|
||||
import pojo.UserRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class BaseTest {
|
||||
protected static RequestSpecification spec;
|
||||
protected static String authToken;
|
||||
protected static UserRequest testUserRequest;
|
||||
protected String addUserId;
|
||||
|
||||
@BeforeClass
|
||||
public void setupTestData() {
|
||||
authToken = PropertyProvider.getProperty("auth.token");
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void setup() throws IOException {
|
||||
spec = Specifications.initRequestSpecification(authToken);
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
public void tearDown() {
|
||||
UserEndpoint.deleteUserById(spec, addUserId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
package tests;
|
||||
|
||||
import endpoints.UserEndpoint;
|
||||
import helpers.PropertyProvider;
|
||||
import io.qameta.allure.Epic;
|
||||
import io.qameta.allure.Feature;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.asserts.SoftAssert;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@Epic("Управление сценариями GET")
|
||||
public class GetAndDeleteUserTest extends BaseTest {
|
||||
|
||||
@Feature("Сценарий с GET")
|
||||
@Test(description = "Проверить, информацию о текущем пользователе и удалить текущего пользователя.")
|
||||
public void testGetCurrentAndDeleteUser() {
|
||||
|
||||
var request = UserEndpoint.addUser();
|
||||
addUserId = request.getId();
|
||||
|
||||
UserEndpoint.addUserId(spec, request);
|
||||
|
||||
var response = UserEndpoint.getUser(spec);
|
||||
response
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("username", equalTo(PropertyProvider.getProperty("test.username")),
|
||||
"firstName", equalTo(PropertyProvider.getProperty("test.firstname")),
|
||||
"lastName", equalTo(PropertyProvider.getProperty("test.lastname")),
|
||||
"email", equalTo(PropertyProvider.getProperty("test.email")));
|
||||
|
||||
UserEndpoint.deleteUser(spec)
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test(description = "Проверить, информацию пользователя по его ID {userId} и удалить по ID")
|
||||
public void testGetUserById() {
|
||||
var softAssert = new SoftAssert();
|
||||
|
||||
var request = UserEndpoint.addUser();
|
||||
addUserId = request.getId();
|
||||
|
||||
UserEndpoint.addUserId(spec, request);
|
||||
|
||||
var userId = PropertyProvider.getProperty("test.id");
|
||||
var response = UserEndpoint.getUserById(spec, userId);
|
||||
|
||||
softAssert.assertNotNull(userId, "ID пользователя не должен быть нулевым");
|
||||
softAssert.assertFalse(userId.trim().isEmpty(), "ID пользователя не должен быть пустым");
|
||||
|
||||
response
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("id", equalTo(userId),
|
||||
"username", equalTo(PropertyProvider.getProperty("test.username")));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package tests;
|
||||
|
||||
import endpoints.UserEndpoint;
|
||||
import io.qameta.allure.Epic;
|
||||
import io.qameta.allure.Feature;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Epic("POST")
|
||||
public class PostUserTest extends BaseTest {
|
||||
|
||||
@Feature("Сценарий с POST")
|
||||
@Test(description = "Проверить создание нового пользователя и его удаление")
|
||||
public void testAddUserSuccessfully() {
|
||||
var request = UserEndpoint
|
||||
.addUser();
|
||||
|
||||
var response = UserEndpoint.addUserId(spec, request);
|
||||
|
||||
addUserId = response.asString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
package tests;
|
||||
|
||||
import endpoints.UserEndpoint;
|
||||
import io.qameta.allure.Epic;
|
||||
import io.qameta.allure.Feature;
|
||||
import org.testng.annotations.Test;
|
||||
import pojo.UserRequest;
|
||||
|
||||
@Epic("PUT")
|
||||
public class PutUserTest extends BaseTest{
|
||||
|
||||
@Feature("Сценарий с PUT (создание - обновление - удаление)")
|
||||
@Test(description = "Проверить, обновление информации о текущем пользователе и удалить его")
|
||||
public void testUpdateUser() {
|
||||
|
||||
var request = UserEndpoint.
|
||||
addUser();
|
||||
addUserId = request.getId();
|
||||
|
||||
UserEndpoint
|
||||
.addUserId(spec, request);
|
||||
|
||||
var updateUser = UserRequest.builder()
|
||||
.username("itc1205" + request.getUsername())
|
||||
.firstName("Kamil" + request.getFirstName())
|
||||
.lastName("Vonuchka" + request.getLastName())
|
||||
.email("kamilka@mail.ru" + request.getEmail())
|
||||
.build();
|
||||
|
||||
UserEndpoint.updateUser(spec, updateUser)
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
UserEndpoint.getUser(spec)
|
||||
.then()
|
||||
.statusCode(200);
|
||||
//эти проверки нужны будут потом
|
||||
// .body("firstName", equalTo(updateUser.getFirstName()),
|
||||
// "email", equalTo(updateUser.getEmail());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
base.url=https://6c61743f-4c3c-4db0-bd41-75698e213f2c.mock.pstmn.io
|
||||
auth.token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30
|
||||
test.id=35790af5-b2fc-2bbd-5d7c-3f83e7f0645f
|
||||
test.username=ivan1205
|
||||
test.firstname=Ivan
|
||||
test.lastname=Aksenov
|
||||
test.email=itc@ya.ru
|
||||
|
||||
endpoint.user = /api/user
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
|
||||
|
||||
<suite name="RestApiUser" parallel="classes" thread-count="3">
|
||||
<test name="Tests">
|
||||
<classes>
|
||||
<class name="tests.GetAndDeleteUserTest"/>
|
||||
<class name="tests.PutUserTest"/>
|
||||
<class name="tests.PostUserTest"/>
|
||||
</classes>
|
||||
</test>
|
||||
</suite>
|
||||
Loading…
Add table
Add a link
Reference in a new issue