forked from anton-liauchuk/educational-platform
-
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.
Showing
7 changed files
with
67 additions
and
1 deletion.
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
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,2 +1,6 @@ | ||
DELETE FROM course_enrollment; | ||
DELETE FROM course; | ||
DELETE FROM student; | ||
|
||
INSERT INTO course (uuid) VALUES ('123E4567E89B12D3A456426655440001'); | ||
INSERT INTO student (username) VALUES ('username'); |
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,7 @@ | ||
dependencies { | ||
implementation project(':users:users-web') | ||
implementation 'org.springframework.boot:spring-boot-starter-security' | ||
implementation 'io.rest-assured:rest-assured:4.2.0' | ||
implementation 'io.rest-assured:json-path:4.2.0' | ||
implementation 'io.rest-assured:xml-path:4.2.0' | ||
} |
34 changes: 34 additions & 0 deletions
34
security/test/src/main/java/com/educational/platform/security/SignUpHelper.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,34 @@ | ||
package com.educational.platform.security; | ||
|
||
import io.restassured.http.ContentType; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
/** | ||
* Represents the component for signing up test user and getting the token. Should be used in API tests. | ||
*/ | ||
@Component | ||
public class SignUpHelper { | ||
|
||
/** | ||
* Signs up the student and returns the token. | ||
* | ||
* @return token. | ||
*/ | ||
public String signUpStudent() { | ||
return given() | ||
.contentType(ContentType.JSON) | ||
.body("{\n" + | ||
" \"role\": \"ROLE_STUDENT\",\n" + | ||
" \"username\": \"username\",\n" + | ||
" \"email\": \"[email protected]\",\n" + | ||
" \"password\": \"password\"\n" + | ||
"}") | ||
|
||
.when() | ||
.post("/users/sign-up") | ||
.asString(); | ||
} | ||
|
||
} |
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