This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from sbtqa/rest-form-fix
Cookie and form
- Loading branch information
Showing
11 changed files
with
159 additions
and
4 deletions.
There are no files selected for viewing
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
19 changes: 19 additions & 0 deletions
19
plugins/rest-plugin/src/main/java/ru/sbtqa/tag/api/annotation/Cookie.java
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ru.sbtqa.tag.api.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Annotate field that must be substitute to request as cookie | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.FIELD) | ||
public @interface Cookie { | ||
|
||
/** | ||
* Cookie name | ||
*/ | ||
String name(); | ||
} |
2 changes: 1 addition & 1 deletion
2
plugins/rest-plugin/src/main/java/ru/sbtqa/tag/api/annotation/ParameterType.java
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,5 @@ | ||
package ru.sbtqa.tag.api.annotation; | ||
|
||
public enum ParameterType { | ||
HEADER, QUERY, BODY | ||
HEADER, QUERY, BODY, COOKIE | ||
} |
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
28 changes: 28 additions & 0 deletions
28
plugins/rest-plugin/src/test/java/ru/sbtqa/tag/api/entries/form/FormEndpointEntry.java
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ru.sbtqa.tag.api.entries.form; | ||
|
||
import ru.sbtqa.tag.api.EndpointEntry; | ||
import ru.sbtqa.tag.api.Rest; | ||
import ru.sbtqa.tag.api.annotation.Body; | ||
import ru.sbtqa.tag.api.annotation.Endpoint; | ||
import ru.sbtqa.tag.api.annotation.Validation; | ||
import ru.sbtqa.tag.api.utils.Default; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
@Endpoint(method = Rest.POST, path = "client/form", title = "form") | ||
public class FormEndpointEntry extends EndpointEntry { | ||
|
||
@Body(name = "id") | ||
private int id = Default.ID; | ||
|
||
@Body(name = "name") | ||
private String name = Default.NAME; | ||
|
||
@Body(name = "email") | ||
private String email = Default.EMAIL; | ||
|
||
@Validation(title = "result") | ||
public void validate() { | ||
getResponse().body("result", equalTo(id + name + email)); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
plugins/rest-plugin/src/test/java/ru/sbtqa/tag/api/entries/parameters/CookieEntry.java
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ru.sbtqa.tag.api.entries.parameters; | ||
|
||
import ru.sbtqa.tag.api.EndpointEntry; | ||
import ru.sbtqa.tag.api.Rest; | ||
import ru.sbtqa.tag.api.annotation.Cookie; | ||
import ru.sbtqa.tag.api.annotation.Endpoint; | ||
import ru.sbtqa.tag.api.annotation.Validation; | ||
import ru.sbtqa.tag.api.utils.Default; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
@Endpoint(method = Rest.GET, path = "client/cookie", title = "cookie") | ||
public class CookieEntry extends EndpointEntry { | ||
|
||
@Cookie(name = Default.COOKIE_NAME) | ||
private String cookie = Default.COOKIE_VALUE; | ||
|
||
@Validation(title = "result") | ||
public void validate() { | ||
getResponse().body("result", equalTo(cookie)); | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
plugins/rest-plugin/src/test/resources/features/Cookie.feature
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#language:en | ||
@cookie | ||
Feature: Send get with cookie | ||
|
||
@cookie | ||
Scenario: Send get with cookie | ||
* user sends request for "cookie" | ||
* system returns "result" |
8 changes: 8 additions & 0 deletions
8
plugins/rest-plugin/src/test/resources/features/FormData.feature
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#language:en | ||
@form | ||
Feature: Send post with form parameters | ||
|
||
@form | ||
Scenario: Send post with form parameters | ||
* user sends request for "form" | ||
* system returns "result" |