From 274658f9b003ff64ae35bc0b6ac4010985d739f8 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Fri, 21 Sep 2007 15:51:36 +0000 Subject: [PATCH] SEC-272: Added group tables to test DB. --- .../org/acegisecurity/PopulatedDatabase.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/org/acegisecurity/PopulatedDatabase.java b/core/src/test/java/org/acegisecurity/PopulatedDatabase.java index 8dc812c597..d01bcfd74f 100644 --- a/core/src/test/java/org/acegisecurity/PopulatedDatabase.java +++ b/core/src/test/java/org/acegisecurity/PopulatedDatabase.java @@ -29,7 +29,7 @@ import javax.sql.DataSource; */ public class PopulatedDatabase { //~ Static fields/initializers ===================================================================================== - + private static DriverManagerDataSource dataSource = null; //~ Constructors =================================================================================================== @@ -98,5 +98,33 @@ public class PopulatedDatabase { template.execute("INSERT INTO acl_permission VALUES (null, 2, 'marissa', 2);"); template.execute("INSERT INTO acl_permission VALUES (null, 3, 'scott', 14);"); template.execute("INSERT INTO acl_permission VALUES (null, 6, 'scott', 1);"); + + // Group tables and data + template.execute( + "CREATE TABLE GROUPS(ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0) PRIMARY KEY, GROUP_NAME VARCHAR_IGNORECASE(50) NOT NULL)"); + template.execute( + "CREATE TABLE GROUP_AUTHORITIES(GROUP_ID BIGINT NOT NULL, AUTHORITY VARCHAR(50) NOT NULL, CONSTRAINT FK_GROUP_AUTHORITIES_GROUP FOREIGN KEY(GROUP_ID) REFERENCES GROUPS(ID))"); + template.execute( + "CREATE TABLE GROUP_MEMBERS(ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0) PRIMARY KEY, USERNAME VARCHAR(50) NOT NULL, GROUP_ID BIGINT NOT NULL, CONSTRAINT FK_GROUP_MEMBERS_GROUP FOREIGN KEY(GROUP_ID) REFERENCES GROUPS(ID))"); + + template.execute("INSERT INTO USERS VALUES('jerry','password',TRUE)"); + template.execute("INSERT INTO USERS VALUES('tom','password',TRUE)"); + + template.execute("INSERT INTO GROUPS VALUES (0, 'GROUP_ZERO')"); + template.execute("INSERT INTO GROUPS VALUES (1, 'GROUP_ONE')"); + template.execute("INSERT INTO GROUPS VALUES (2, 'GROUP_TWO')"); + + template.execute("INSERT INTO GROUP_AUTHORITIES VALUES (0, 'ROLE_A')"); + template.execute("INSERT INTO GROUP_AUTHORITIES VALUES (1, 'ROLE_B')"); + template.execute("INSERT INTO GROUP_AUTHORITIES VALUES (1, 'ROLE_C')"); + template.execute("INSERT INTO GROUP_AUTHORITIES VALUES (2, 'ROLE_A')"); + template.execute("INSERT INTO GROUP_AUTHORITIES VALUES (2, 'ROLE_B')"); + template.execute("INSERT INTO GROUP_AUTHORITIES VALUES (2, 'ROLE_C')"); + + template.execute("INSERT INTO GROUP_MEMBERS VALUES (0, 'jerry', 0)"); + template.execute("INSERT INTO GROUP_MEMBERS VALUES (1, 'jerry', 1)"); + // tom has groups with overlapping roles + template.execute("INSERT INTO GROUP_MEMBERS VALUES (2, 'tom', 1)"); + template.execute("INSERT INTO GROUP_MEMBERS VALUES (3, 'tom', 2)"); } }