This repository was archived by the owner on Apr 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/user registration steps #30
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
31 changes: 31 additions & 0 deletions
31
src/test/java/de/filefighter/rest/cucumber/UserRegistrationSteps.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package de.filefighter.rest.cucumber; | ||
|
||
import de.filefighter.rest.RestApplicationIntegrationTest; | ||
import io.cucumber.java.en.When; | ||
import org.springframework.http.HttpMethod; | ||
|
||
import java.util.HashMap; | ||
|
||
import static de.filefighter.rest.configuration.RestConfiguration.*; | ||
|
||
public class UserRegistrationSteps extends RestApplicationIntegrationTest { | ||
@When("user requests registration with username {string}, password {string} and password confirmation {string} with accessToken {string}") | ||
public void userRequestsRegistrationWithUsernamePasswordAndPasswordConfirmationWithAccessToken(String username, String password, String passwordConfirmation, String accessToken) { | ||
|
||
String authHeaderString = AUTHORIZATION_BEARER_PREFIX + accessToken; | ||
String url = BASE_API_URI + USER_BASE_URI + "register"; | ||
|
||
|
||
HashMap<String, String> authHeader = new HashMap<>(); | ||
authHeader.put("Authorization", authHeaderString); | ||
|
||
|
||
|
||
|
||
String postBody=serializeUser(password,null,password,username); | ||
|
||
executeRestApiCall(HttpMethod.POST, url, authHeader,postBody); | ||
|
||
|
||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,61 @@ | ||
#Feature: User Registration | ||
# As a user (/admin) | ||
# I want to be able to register (users) with username and password | ||
# | ||
# Background: | ||
# Given database is empty | ||
# And user with id 1234 exists and has username "user", password "secure_password" | ||
# And accessToken with value "accessToken" exists for user 1234 | ||
# And user with id 1234 is in group with id 1 | ||
# | ||
# Scenario: Successful registration with username, password and password confirmation. | ||
# When user requests registration with username "kangaroo", password "pig-system" and password confirmation "pig-system" with accessToken "accessToken" | ||
# Then response status code is 201 | ||
# And response contains key "message" and value "User successfully created." | ||
# And response contains key "status" and value "created" | ||
# | ||
# Scenario: Successful registration with username, password and password confirmation; password matches password of other users. | ||
# When user requests registration with username "kangaroo", password "secure_password" and password confirmation "secure_password" with accessToken "accessToken" | ||
# Then response status code is 201 | ||
# And response contains key "message" and value "User successfully created." | ||
# And response contains key "status" and value "created" | ||
# | ||
# Scenario: Failed registration with used username, arbitrary password and password confirmation. | ||
# When user requests registration with username "user", password "pig-system" and password confirmation "pig-system" with accessToken "accessToken" | ||
# Then response status code is 409 | ||
# And response contains key "message" and value "User already exists." | ||
# And response contains key "status" and value "conflict" | ||
# | ||
# Scenario: Failed registration with used username (other case), arbitrary password and password confirmation. | ||
# When user requests registration with username "User", password "pig-system" and password confirmation "pig-system" with accessToken "accessToken" | ||
# Then response status code is 409 | ||
# And response contains key "message" and value "User already exists." | ||
# And response contains key "status" and value "conflict" | ||
# | ||
# Scenario: Failed registration with username, password and deviating password confirmation. | ||
# When user requests registration with username "kangaroo", password "pig-system" and password confirmation "i-love-capitalism" with accessToken "accessToken" | ||
# Then response status code is 409 | ||
# And response contains key "message" and value "Passwords do not match." | ||
# And response contains key "status" and value "conflict" | ||
# | ||
# Scenario: Failed registration with username, password and password confirmation; username is part of password. | ||
# When user requests registration with username "kangaroo", password "kangaroo-system" and password confirmation "kangaroo-system" with accessToken "accessToken" | ||
# Then response status code is 409 | ||
# And response contains key "message" and value "Username must not appear in password." | ||
# And response contains key "status" and value "conflict" | ||
# | ||
# Scenario: Failed registration with username, password and password confirmation; password appears in list of top 10k passwords | ||
# When user requests registration with username "kangaroo", password "vietnam" and password confirmation "vietnam" with accessToken "accessToken" | ||
# Then response status code is 409 | ||
# And response contains key "message" and value "Password must not appear in the top 10000 most common passwords." | ||
# And response contains key "status" and value "conflict" | ||
# #https://github.com/iryndin/10K-Most-Popular-Passwords/blob/master/passwords.txt | ||
# | ||
# Scenario: Failed registration with username, password and password confirmation; not in group ADMIN | ||
# Given user with id 1236 exists | ||
# And user with id 1236 is in group with id -1 | ||
# And accessToken with value "wrongAccessToken" exists for user 1236 | ||
# When user requests registration with username "kangaroo", password "pig-system" and password confirmation "pig-system" with accessToken "wrongAccessToken" | ||
# Then response status code is 401 | ||
# And response contains key "message" and value "User must not register new users." | ||
# And response contains key "status" and value "unauthorized" | ||
Feature: User Registration | ||
As a user (/admin) | ||
I want to be able to register (users) with username and password | ||
|
||
Background: | ||
Given database is empty | ||
And user with id 1234 exists and has username "user", password "secure_password" | ||
And accessToken with value "accessToken" exists for user 1234 | ||
And user with id 1234 is in group with id 1 | ||
|
||
Scenario: Successful registration with username, password and password confirmation. | ||
When user requests registration with username "kangaroo", password "pig-system" and password confirmation "pig-system" with accessToken "accessToken" | ||
Then response status code is 201 | ||
And response contains key "message" and value "User successfully created." | ||
And response contains key "status" and value "created" | ||
|
||
Scenario: Successful registration with username, password and password confirmation; password matches password of other users. | ||
When user requests registration with username "kangaroo", password "secure_password" and password confirmation "secure_password" with accessToken "accessToken" | ||
Then response status code is 201 | ||
And response contains key "message" and value "User successfully created." | ||
And response contains key "status" and value "created" | ||
|
||
Scenario: Failed registration with used username, arbitrary password and password confirmation. | ||
When user requests registration with username "user", password "pig-system" and password confirmation "pig-system" with accessToken "accessToken" | ||
Then response status code is 409 | ||
And response contains key "message" and value "User already exists." | ||
And response contains key "status" and value "conflict" | ||
|
||
Scenario: Failed registration with used username (other case), arbitrary password and password confirmation. | ||
When user requests registration with username "User", password "pig-system" and password confirmation "pig-system" with accessToken "accessToken" | ||
Then response status code is 409 | ||
And response contains key "message" and value "User already exists." | ||
And response contains key "status" and value "conflict" | ||
|
||
Scenario: Failed registration with username, password and deviating password confirmation. | ||
When user requests registration with username "kangaroo", password "pig-system" and password confirmation "i-love-capitalism" with accessToken "accessToken" | ||
Then response status code is 409 | ||
And response contains key "message" and value "Passwords do not match." | ||
And response contains key "status" and value "conflict" | ||
|
||
Scenario: Failed registration with username, password and password confirmation; username is part of password. | ||
When user requests registration with username "kangaroo", password "kangaroo-system" and password confirmation "kangaroo-system" with accessToken "accessToken" | ||
Then response status code is 409 | ||
And response contains key "message" and value "Username must not appear in password." | ||
And response contains key "status" and value "conflict" | ||
|
||
Scenario: Failed registration with username, password and password confirmation; password appears in list of top 10k passwords | ||
When user requests registration with username "kangaroo", password "vietnam" and password confirmation "vietnam" with accessToken "accessToken" | ||
Then response status code is 409 | ||
And response contains key "message" and value "Password must not appear in the top 10000 most common passwords." | ||
And response contains key "status" and value "conflict" | ||
#https://github.com/iryndin/10K-Most-Popular-Passwords/blob/master/passwords.txt | ||
|
||
Scenario: Failed registration with username, password and password confirmation; not in group ADMIN | ||
Given user 1236 exists | ||
And user with id 1236 is in group with id -1 | ||
And accessToken with value "wrongAccessToken" exists for user 1236 | ||
When user requests registration with username "kangaroo", password "pig-system" and password confirmation "pig-system" with accessToken "wrongAccessToken" | ||
Then response status code is 401 | ||
And response contains key "message" and value "User must not register new users." | ||
And response contains key "status" and value "unauthorized" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.