Skip to content

Commit 3ab011b

Browse files
committed
Adding a new user to ocvn. We need to update the database initialization script and we need to add the new user to EmbeddedController and ExternalController. For adding the password into the database, the password is encoded using StandardPasswordEncoder in Spring. This encoder uses SHA-256 hashing with 1024 iterations and a random 8-byte random salt value.
1 parent 77aaf19 commit 3ab011b

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

jdk_8_maven/em/embedded/rest/ocvn/src/main/java/em/embedded/org/devgateway/ocvn/EmbeddedEvoMasterController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ public void resetStateOfSUT() {
146146

147147
@Override
148148
public List<AuthenticationDto> getInfoForAuthentication() {
149-
return Arrays.asList(AuthUtils.getForDefaultSpringFormLogin("ADMIN", "admin", "admin"));
149+
150+
// Adding a new user called user1 with password "password". User details are stored in the database.
151+
152+
return Arrays.asList(
153+
AuthUtils.getForDefaultSpringFormLogin("ADMIN", "admin", "admin"),
154+
AuthUtils.getForDefaultSpringFormLogin("user1", "user1", "password"));
150155
}
151156

152157

jdk_8_maven/em/embedded/rest/ocvn/src/main/resources/init_db.sql

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,35 @@ VALUES
3434
NULL
3535
);
3636

37+
INSERT INTO PERSON
38+
(
39+
CHANGE_PASSWORD,
40+
COUNTRY,
41+
EMAIL,
42+
ENABLED,
43+
FIRST_NAME,
44+
LAST_NAME,
45+
PASSWORD,
46+
TITLE,
47+
USERNAME,
48+
GROUP_ID
49+
)
50+
VALUES
51+
(
52+
false,
53+
NULL,
54+
NULL,
55+
true,
56+
NULL,
57+
NULL,
58+
'b65d4278fb536a6e1ea23c87988f5d79ef743ccb07b2067ad8ebd52f1a0c067e5bc3b7f76eca3abc',
59+
NULL,
60+
'user1',
61+
NULL
62+
);
63+
3764
INSERT INTO PERSON_ROLES(PERSON_ID,ROLES_ID)VALUES(1,2);
3865
INSERT INTO PERSON_ROLES(PERSON_ID,ROLES_ID)VALUES(1,1);
3966
INSERT INTO PERSON_ROLES(PERSON_ID,ROLES_ID)VALUES(1,3);
67+
68+
INSERT INTO PERSON_ROLES(PERSON_ID,ROLES_ID)VALUES(2,1);

jdk_8_maven/em/external/rest/ocvn/src/main/java/em/external/org/devgateway/ocvn/ExternalEvoMasterController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,12 @@ public SutInfoDto.OutputFormat getPreferredOutputFormat() {
239239

240240
@Override
241241
public List<AuthenticationDto> getInfoForAuthentication() {
242-
return Arrays.asList(AuthUtils.getForDefaultSpringFormLogin("ADMIN", "admin", "admin"));
242+
243+
// Adding a new user called user1 with password "password". User details are stored in the database.
244+
245+
return Arrays.asList(
246+
AuthUtils.getForDefaultSpringFormLogin("ADMIN", "admin", "admin"),
247+
AuthUtils.getForDefaultSpringFormLogin("user1", "user1", "password"));
243248
}
244249

245250

0 commit comments

Comments
 (0)