|
|
@ -1,5 +1,11 @@ |
|
|
|
package org.waterproofingdata.wpdauth.integrationtest; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
import com.google.gson.Gson; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows; |
|
|
@ -10,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.boot.test.context.SpringBootTest; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.waterproofingdata.wpdauth.exception.CustomException; |
|
|
|
import org.waterproofingdata.wpdauth.model.Roles; |
|
|
|
import org.waterproofingdata.wpdauth.model.Users; |
|
|
|
import org.waterproofingdata.wpdauth.service.UsersService; |
|
|
|
|
|
|
|
@SpringBootTest |
|
|
@ -34,4 +42,19 @@ public class UsersServiceIntegrationTest { |
|
|
|
String login = usersService.login("admin", "admin"); |
|
|
|
assertNotNull(login, "Login token returned from usersService.login() should not be null"); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testRandomUserSignup() { |
|
|
|
Users u = new Users(); |
|
|
|
String uName = String.format("user%s", UUID.randomUUID().toString()); |
|
|
|
String uEmail = String.format("%s@email.com", uName); |
|
|
|
u.setUsername(uName); |
|
|
|
u.setPassword(UUID.randomUUID().toString()); |
|
|
|
u.setEmail(uEmail); |
|
|
|
u.setRoles(new ArrayList<Roles>(Arrays.asList(Roles.ROLE_CLIENT))); |
|
|
|
String uJson = new Gson().toJson(u); |
|
|
|
|
|
|
|
String signup = usersService.signup(u); |
|
|
|
assertNotNull(signup, "Signup token returned from usersService.signup(user) should not be null"); |
|
|
|
} |
|
|
|
} |