From 169a3b8ae26c3ec65c226c4e23cf95fa4c861d5c Mon Sep 17 00:00:00 2001 From: EgorSivenko Date: Wed, 17 Apr 2024 21:02:34 +0300 Subject: [PATCH] Encrypted passwords in sql script with test data --- .../resources/db/migration/V2__populate_test_data.sql | 9 ++++++--- .../urlshortener/link/LinkRepositoryTest.java | 2 +- .../urlshortener/user/UserRepositoryTest.java | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/resources/db/migration/V2__populate_test_data.sql b/src/main/resources/db/migration/V2__populate_test_data.sql index 1b5e805..95ecb7f 100644 --- a/src/main/resources/db/migration/V2__populate_test_data.sql +++ b/src/main/resources/db/migration/V2__populate_test_data.sql @@ -1,7 +1,10 @@ INSERT INTO users (id, email, password, role) -VALUES ('84991c79-f6a9-4b7b-b1b4-0d66c0b92c81', 'user1@example.com', 'password1', 'USER'), - ('f6ff4ee4-92c4-49f3-97eb-d6c69a715325', 'user2@example.com', 'password2', 'USER'), - ('b95cb1b3-1a7e-4e8b-a7ef-f3e20aef5f0a', 'user3@example.com', 'password3', 'ADMIN'); +VALUES ('84991c79-f6a9-4b7b-b1b4-0d66c0b92c81', 'user1@example.com', + '$2a$12$7Cp4On1DBNyCkz4TaZYc3O.A.CBKi4WXgXnlI4SD0yn7CgBX5Gd6O', 'USER'), + ('f6ff4ee4-92c4-49f3-97eb-d6c69a715325', 'user2@example.com', + '$2a$12$7Cp4On1DBNyCkz4TaZYc3O.A.CBKi4WXgXnlI4SD0yn7CgBX5Gd6O', 'USER'), + ('b95cb1b3-1a7e-4e8b-a7ef-f3e20aef5f0a', 'user3@example.com', + '$2a$12$7Cp4On1DBNyCkz4TaZYc3O.A.CBKi4WXgXnlI4SD0yn7CgBX5Gd6O', 'ADMIN'); INSERT INTO links (id, long_link, short_link, user_id, created_time, expiration_time, statistics, status) VALUES ('3053e49b-6da3-4389-9d06-23b2d57b6f25', 'https://www.youtube.com', 'short-link-1', diff --git a/src/test/java/com/linkurlshorter/urlshortener/link/LinkRepositoryTest.java b/src/test/java/com/linkurlshorter/urlshortener/link/LinkRepositoryTest.java index 164f15d..8a082f9 100644 --- a/src/test/java/com/linkurlshorter/urlshortener/link/LinkRepositoryTest.java +++ b/src/test/java/com/linkurlshorter/urlshortener/link/LinkRepositoryTest.java @@ -38,7 +38,7 @@ void setUp() { .user(User.builder() .id(UUID.fromString("84991c79-f6a9-4b7b-b1b4-0d66c0b92c81")) .email("user1@example.com") - .password("password1") + .password("$2a$12$7Cp4On1DBNyCkz4TaZYc3O.A.CBKi4WXgXnlI4SD0yn7CgBX5Gd6O") .role(UserRole.USER) .build()) .createdTime(LocalDateTime.of(2024, 4, 13, 10, 0)) diff --git a/src/test/java/com/linkurlshorter/urlshortener/user/UserRepositoryTest.java b/src/test/java/com/linkurlshorter/urlshortener/user/UserRepositoryTest.java index f255ed1..0fb0592 100644 --- a/src/test/java/com/linkurlshorter/urlshortener/user/UserRepositoryTest.java +++ b/src/test/java/com/linkurlshorter/urlshortener/user/UserRepositoryTest.java @@ -31,7 +31,7 @@ void setUp() { user = User.builder() .id(UUID.fromString("84991c79-f6a9-4b7b-b1b4-0d66c0b92c81")) .email("user1@example.com") - .password("password1") + .password("$2a$12$7Cp4On1DBNyCkz4TaZYc3O.A.CBKi4WXgXnlI4SD0yn7CgBX5Gd6O") .role(UserRole.USER) .build(); }