cleaned out broken unit tests -- now we can start fresh
parent
c9bdba3f3a
commit
217916603f
|
@ -1,299 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright 2012 The MITRE Corporation
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
******************************************************************************/
|
|
||||||
package org.mitre.jdbc.datasource;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
import org.mitre.jdbc.datasource.util.SqlFileParser;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* @author Matt Franklin
|
|
||||||
* <p/>
|
|
||||||
* Creates a JDBC DataSource that is fully initialized with the schema and data referenced in the
|
|
||||||
* application context.
|
|
||||||
* <p/>
|
|
||||||
* <p/>
|
|
||||||
* Usage:
|
|
||||||
* <code>
|
|
||||||
* <bean id="dataSource" class="org.mitre.jdbc.datasource.H2DataSourceFactory">
|
|
||||||
* <property name="databaseName" value="mymii"/>
|
|
||||||
* <property name="persist" value="true" />
|
|
||||||
* <property name="executeScriptQuery" value="SELECT * FROM gadgets" />
|
|
||||||
* <property name="scriptLocations" >
|
|
||||||
* <list>
|
|
||||||
* <value>file:db/sequences/create_all_seq.sql</value>
|
|
||||||
* <value>file:db/tables/create_all_tables.sql</value>
|
|
||||||
* <value>classpath:test-data.sql</value>
|
|
||||||
* </list>
|
|
||||||
* </property>
|
|
||||||
* </bean>
|
|
||||||
* </code>
|
|
||||||
* <p/>
|
|
||||||
*/
|
|
||||||
public class H2DataSourceFactory implements FactoryBean {
|
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(H2DataSourceFactory.class);
|
|
||||||
|
|
||||||
protected String databaseName;
|
|
||||||
protected Boolean persist;
|
|
||||||
protected String executeScriptQuery;
|
|
||||||
protected List<Resource> scriptLocations;
|
|
||||||
protected Map<String, String> dateConversionPatterns;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The DataSource singleton returned by the factory.
|
|
||||||
*/
|
|
||||||
protected DataSource dataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new factory with no initial values for required properties.
|
|
||||||
* <p/>
|
|
||||||
* NOTE: If the factory is initialized using the default constructor, the required properties must be set prior to use
|
|
||||||
*/
|
|
||||||
public H2DataSourceFactory() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new factory and sets teh properties to the passed in parameters
|
|
||||||
*
|
|
||||||
* @param databaseName {@see setDatabaseName}
|
|
||||||
* @param scriptLocations {@see setScriptLocations}
|
|
||||||
* @param persist {@see setPersist}
|
|
||||||
* @param executeScriptQuery {@see setLoadDataQuery}
|
|
||||||
* @param dateConversionPatterns {@see setDateConversionPatterns}
|
|
||||||
*/
|
|
||||||
public H2DataSourceFactory(String databaseName, List<Resource> scriptLocations, Boolean persist, String executeScriptQuery, Map<String, String> dateConversionPatterns) {
|
|
||||||
setDatabaseName(databaseName);
|
|
||||||
setScriptLocations(scriptLocations);
|
|
||||||
setPersist(persist);
|
|
||||||
setExecuteScriptQuery(executeScriptQuery);
|
|
||||||
setDateConversionPatterns(dateConversionPatterns);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional property
|
|
||||||
* <p/>
|
|
||||||
* Sets a map of conversion patterns to register with the Oracle conversion utilities
|
|
||||||
*
|
|
||||||
* @param dateConversionPatterns map of patterns keyed by Oracle syntax with a value of a {@link java.text.DateFormat}
|
|
||||||
*/
|
|
||||||
public void setDateConversionPatterns(Map<String, String> dateConversionPatterns) {
|
|
||||||
this.dateConversionPatterns = dateConversionPatterns;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional Property
|
|
||||||
* <p/>
|
|
||||||
* Sets whether or not to persist the database
|
|
||||||
*
|
|
||||||
* @param persist boolean value
|
|
||||||
*/
|
|
||||||
public void setPersist(Boolean persist) {
|
|
||||||
this.persist = persist;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional Property
|
|
||||||
* <p/>
|
|
||||||
* Set the query used to determine whether or not to execute the scripts on initialization
|
|
||||||
*
|
|
||||||
* @param executeScriptQuery the query to execute. If there are no results of the query, the scripts referenced
|
|
||||||
* in setScriptLocations will be executed. The statement must be a select statement.
|
|
||||||
*/
|
|
||||||
public void setExecuteScriptQuery(String executeScriptQuery) {
|
|
||||||
this.executeScriptQuery = executeScriptQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Required Property
|
|
||||||
* <p/>
|
|
||||||
* Sets the name of the in memory database/schema
|
|
||||||
*
|
|
||||||
* @param databaseName the name such as "mymii"
|
|
||||||
*/
|
|
||||||
public void setDatabaseName(String databaseName) {
|
|
||||||
this.databaseName = databaseName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Required Property
|
|
||||||
* <p/>
|
|
||||||
* Sets the locations of the files containing DDL to be executed against the database
|
|
||||||
* <p/>
|
|
||||||
* NOTE: Files are executed in order
|
|
||||||
*
|
|
||||||
* @param scriptLocations list of {@link Resource} compatible location strings
|
|
||||||
*/
|
|
||||||
public void setScriptLocations(List<Resource> scriptLocations) {
|
|
||||||
this.scriptLocations = scriptLocations;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void initializeFactory() {
|
|
||||||
validateProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getObject() throws Exception {
|
|
||||||
return getDataSource();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class getObjectType() {
|
|
||||||
return DataSource.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSingleton() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the singleton DataSource if created. Initializes if not already created.
|
|
||||||
*
|
|
||||||
* @return the DataSource
|
|
||||||
*/
|
|
||||||
public DataSource getDataSource() {
|
|
||||||
if (dataSource == null) {
|
|
||||||
initializeDataSource();
|
|
||||||
}
|
|
||||||
return dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Helper methods
|
|
||||||
*/
|
|
||||||
protected void validateProperties() {
|
|
||||||
if (databaseName == null) {
|
|
||||||
throw new IllegalArgumentException("The name of the test database to create is required");
|
|
||||||
}
|
|
||||||
if (scriptLocations == null) {
|
|
||||||
throw new IllegalArgumentException("The path to the database schema DDL is required");
|
|
||||||
}
|
|
||||||
if(persist == null) {
|
|
||||||
persist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void initializeDataSource() {
|
|
||||||
this.dataSource = createDataSource();
|
|
||||||
populateDataSourceIfNecessary();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DataSource createDataSource() {
|
|
||||||
DriverManagerDataSource ds = new DriverManagerDataSource();
|
|
||||||
ds.setDriverClassName("org.h2.Driver");
|
|
||||||
ds.setUrl(getConnectionString());
|
|
||||||
ds.setUsername("sa");
|
|
||||||
ds.setPassword("");
|
|
||||||
logger.debug("Created dataSource: " + ds.toString());
|
|
||||||
return ds;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getConnectionString() {
|
|
||||||
return persist ?
|
|
||||||
"jdbc:h2:file:" + databaseName + ";MODE=MySQL" :
|
|
||||||
"jdbc:h2:mem:" + databaseName + ";MODE=MySQL;DB_CLOSE_DELAY=-1";
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void populateDataSourceIfNecessary() {
|
|
||||||
Connection conn = null;
|
|
||||||
try {
|
|
||||||
conn = dataSource.getConnection();
|
|
||||||
if (!persist || testExecuteScriptQuery(conn, executeScriptQuery)) {
|
|
||||||
logger.debug("Database is empty. Loading script files");
|
|
||||||
executeScripts(conn, scriptLocations);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
logger.error("Error querying or populating database", e);
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} finally {
|
|
||||||
closeConnection(conn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Static Helper methods
|
|
||||||
*/
|
|
||||||
protected static void executeScripts(Connection connection, List<Resource> resources) {
|
|
||||||
for (Resource script : resources) {
|
|
||||||
try {
|
|
||||||
String sql = new SqlFileParser(script).getSQL();
|
|
||||||
logger.debug("Executing sql:\n" + sql);
|
|
||||||
executeSql(sql, connection);
|
|
||||||
logger.debug("Successfully executed statement");
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException("File IO Exception while loading " + script.getFilename(), e);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new RuntimeException("SQL exception occurred loading data from " + script.getFilename(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static boolean testExecuteScriptQuery(Connection conn, String executeScriptQuery) {
|
|
||||||
boolean result;
|
|
||||||
try {
|
|
||||||
//If the ResultSet has any rows, the first method will return true
|
|
||||||
result = !executeQuery(conn, executeScriptQuery).first();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
//Only return true if the exception we got is that the table was not found
|
|
||||||
result = e.getMessage().toLowerCase().matches("table \".*\" not found.*\n*.*");
|
|
||||||
}
|
|
||||||
logger.debug("Executed query " + executeScriptQuery + " with result " + result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void closeConnection(Connection conn) {
|
|
||||||
if (conn != null) {
|
|
||||||
try {
|
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
logger.error("Error closing connection to database", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static ResultSet executeQuery(Connection conn, String executeScriptQuery) throws SQLException {
|
|
||||||
Statement statement = conn.createStatement();
|
|
||||||
return statement.executeQuery(executeScriptQuery);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected static void executeSql(String sql, Connection connection) throws SQLException {
|
|
||||||
Statement statement = connection.createStatement();
|
|
||||||
statement.execute(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,164 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright 2012 The MITRE Corporation
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
******************************************************************************/
|
|
||||||
package org.mitre.jdbc.datasource.util;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.Stack;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Matt Franklin
|
|
||||||
*
|
|
||||||
* Parses a file looking for create, alter, insert, update, delete or
|
|
||||||
* drop commands and appends them to an output string or follows @@
|
|
||||||
* syntax to read child scripts.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SqlFileParser {
|
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SqlFileParser.class);
|
|
||||||
|
|
||||||
private static final Pattern WORD_PATTERN = Pattern
|
|
||||||
.compile("^([a-zA-Z]*)[ ;]");
|
|
||||||
private static final String CHILD_SCRIPT_INDICATOR = "@@";
|
|
||||||
private static final Set<String> commandSet;
|
|
||||||
|
|
||||||
static {
|
|
||||||
commandSet = new HashSet<String>();
|
|
||||||
commandSet.add("create");
|
|
||||||
commandSet.add("alter");
|
|
||||||
commandSet.add("insert");
|
|
||||||
commandSet.add("update");
|
|
||||||
commandSet.add("drop");
|
|
||||||
commandSet.add("delete");
|
|
||||||
commandSet.add("commit");
|
|
||||||
commandSet.add("set");
|
|
||||||
commandSet.add("truncate");
|
|
||||||
commandSet.add("rollback");
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum State {
|
|
||||||
INIT, READFILE, READSQL
|
|
||||||
}
|
|
||||||
|
|
||||||
private Stack<State> stateStack;
|
|
||||||
private Resource resource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor takes a Spring {@link Resource}
|
|
||||||
*
|
|
||||||
* @param resource
|
|
||||||
* the initial file to parse
|
|
||||||
*/
|
|
||||||
public SqlFileParser(Resource resource) {
|
|
||||||
stateStack = new Stack<State>();
|
|
||||||
this.resource = resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the executable SQL statements from the resource passed to the
|
|
||||||
* constructor and its children
|
|
||||||
*
|
|
||||||
* @return a valid executable string containing SQL statements
|
|
||||||
* @throws IOException
|
|
||||||
* if the resource or its children are not found
|
|
||||||
*/
|
|
||||||
public String getSQL() throws IOException {
|
|
||||||
return processResource(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String processResource(Resource res) throws IOException {
|
|
||||||
StringBuilder sql = new StringBuilder();
|
|
||||||
File resourceFile = res.getFile();
|
|
||||||
stateStack.push(State.INIT);
|
|
||||||
processFile(resourceFile, sql);
|
|
||||||
stateStack.pop();
|
|
||||||
|
|
||||||
logger.debug(" SQL:: " + sql);
|
|
||||||
|
|
||||||
return sql.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processFile(File file, StringBuilder sql) throws IOException {
|
|
||||||
BufferedReader fileReader = new BufferedReader(new FileReader(
|
|
||||||
file.getAbsoluteFile()));
|
|
||||||
String line = null;
|
|
||||||
while ((line = fileReader.readLine()) != null) {
|
|
||||||
processLine(sql, line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processLine(StringBuilder sql, String line) throws IOException {
|
|
||||||
String lowerLine = line.toLowerCase().trim();
|
|
||||||
switch (stateStack.peek()) {
|
|
||||||
case INIT: {
|
|
||||||
if (lowerLine.startsWith(CHILD_SCRIPT_INDICATOR)) {
|
|
||||||
// replace the current element in the stack with the new state
|
|
||||||
stateStack.pop();
|
|
||||||
stateStack.push(State.READFILE);
|
|
||||||
processLine(sql, line);
|
|
||||||
} else if (commandSet.contains(getFirstWord(lowerLine))) {
|
|
||||||
|
|
||||||
// replace the current element in the stack with the new state
|
|
||||||
stateStack.pop();
|
|
||||||
stateStack.push(State.READSQL);
|
|
||||||
processLine(sql, line);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case READFILE: {
|
|
||||||
stateStack.push(State.INIT);
|
|
||||||
Resource child = resource.createRelative(line.replace(
|
|
||||||
CHILD_SCRIPT_INDICATOR, ""));
|
|
||||||
sql.append(processResource(child));
|
|
||||||
// Read File lines do not have a terminal character but are by
|
|
||||||
// definition only one line Long
|
|
||||||
stateStack.pop();
|
|
||||||
stateStack.push(State.INIT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case READSQL: {
|
|
||||||
sql.append(line);
|
|
||||||
// add a space to accommodate line breaks. Not a big deal if
|
|
||||||
// extraneous spaces are added
|
|
||||||
sql.append(" ");
|
|
||||||
if (lowerLine.endsWith(";")) {
|
|
||||||
stateStack.pop();
|
|
||||||
stateStack.push(State.INIT);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
throw new RuntimeException("Invalid State");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getFirstWord(String line) {
|
|
||||||
Matcher match = WORD_PATTERN.matcher(line);
|
|
||||||
return match.find() ? match.group(1) : null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:jwt-signer="http://www.mitre.org/schema/openid-connect/jwt-signer"
|
|
||||||
xsi:schemaLocation=
|
|
||||||
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
|
||||||
http://www.mitre.org/schema/openid-connect/jwt-signer http://www.mitre.org/schema/openid-connect/jwt-signer/jwt-signer-1.0.xsd" >
|
|
||||||
|
|
||||||
<!-- Creates an in-memory database populated with test jdbc -->
|
|
||||||
<bean id="dataSource" class="org.mitre.jdbc.datasource.H2DataSourceFactory">
|
|
||||||
<property name="databaseName" value="connect"/>
|
|
||||||
<property name="scriptLocations" >
|
|
||||||
<list>
|
|
||||||
<!-- OpenID Connect Data model -->
|
|
||||||
<value>file:db/tables/accesstoken.sql</value>
|
|
||||||
<value>file:db/tables/address.sql</value>
|
|
||||||
<value>file:db/tables/approvedsite.sql</value>
|
|
||||||
<value>file:db/tables/authorities.sql</value>
|
|
||||||
<value>file:db/tables/clientdetails.sql</value>
|
|
||||||
<value>file:db/tables/event.sql</value>
|
|
||||||
<value>file:db/tables/granttypes.sql</value>
|
|
||||||
<value>file:db/tables/idtoken.sql</value>
|
|
||||||
<value>file:db/tables/idtokenclaims.sql</value>
|
|
||||||
<value>file:db/tables/refreshtoken.sql</value>
|
|
||||||
<value>file:db/tables/scope.sql</value>
|
|
||||||
<value>file:db/tables/userinfo.sql</value>
|
|
||||||
<value>file:db/tables/whitelistedsite.sql</value>
|
|
||||||
<!-- Preloaded data -->
|
|
||||||
<value>classpath:test-data.sql</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
<property name="dateConversionPatterns">
|
|
||||||
<map>
|
|
||||||
<entry key="yyyy/mm/dd hh24:mi:ss" value="yyy/MM/dd HH:mm:ss" />
|
|
||||||
<entry key="yyyy-mm-dd" value="yyyy-MM-dd" />
|
|
||||||
</map>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
</beans>
|
|
|
@ -1,53 +0,0 @@
|
||||||
package org.mitre.openid.connect.repository.impl;
|
|
||||||
|
|
||||||
import static org.easymock.EasyMock.createMock;
|
|
||||||
import static org.easymock.EasyMock.expect;
|
|
||||||
import static org.easymock.EasyMock.expectLastCall;
|
|
||||||
import static org.easymock.EasyMock.replay;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
|
||||||
@ContextConfiguration(locations = { "classpath:test-context.xml" })
|
|
||||||
public class JpaNonceRepositoryTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getById_valid() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getById_invalid() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void remove_valid() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void remove_invalid() {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getExpired() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getByClientId_valid() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getByClientId_invalid() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,41 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
|
|
||||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
|
||||||
|
|
||||||
<!-- Appenders -->
|
|
||||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
|
||||||
<param name="Target" value="System.out" />
|
|
||||||
<layout class="org.apache.log4j.PatternLayout">
|
|
||||||
<param name="ConversionPattern" value="%-5p: %c - %m%n" />
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- Application Loggers -->
|
|
||||||
<logger name="org.mitre.openid">
|
|
||||||
<level value="info" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<!-- 3rdparty Loggers -->
|
|
||||||
<logger name="org.springframework.core">
|
|
||||||
<level value="info" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<logger name="org.springframework.beans">
|
|
||||||
<level value="info" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<logger name="org.springframework.context">
|
|
||||||
<level value="info" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<logger name="org.springframework.web">
|
|
||||||
<level value="info" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<!-- Root Logger -->
|
|
||||||
<root>
|
|
||||||
<priority value="info" />
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</root>
|
|
||||||
|
|
||||||
</log4j:configuration>
|
|
|
@ -1,51 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:jwt-signer="http://www.mitre.org/schema/openid-connect/jwt-signer"
|
|
||||||
xsi:schemaLocation=
|
|
||||||
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
|
||||||
http://www.mitre.org/schema/openid-connect/jwt-signer http://www.mitre.org/schema/openid-connect/jwt-signer/jwt-signer-1.0.xsd" >
|
|
||||||
|
|
||||||
<!-- Creates an in-memory database populated with test jdbc -->
|
|
||||||
<bean id="dataSource" class="org.mitre.jdbc.datasource.H2DataSourceFactory">
|
|
||||||
<property name="databaseName" value="connect"/>
|
|
||||||
<property name="scriptLocations" >
|
|
||||||
<list>
|
|
||||||
<!-- OpenID Connect Data model -->
|
|
||||||
<value>file:db/tables/accesstoken.sql</value>
|
|
||||||
<value>file:db/tables/address.sql</value>
|
|
||||||
<value>file:db/tables/approvedsite.sql</value>
|
|
||||||
<value>file:db/tables/authorities.sql</value>
|
|
||||||
<value>file:db/tables/clientdetails.sql</value>
|
|
||||||
<value>file:db/tables/event.sql</value>
|
|
||||||
<value>file:db/tables/granttypes.sql</value>
|
|
||||||
<value>file:db/tables/idtoken.sql</value>
|
|
||||||
<value>file:db/tables/idtokenclaims.sql</value>
|
|
||||||
<value>file:db/tables/refreshtoken.sql</value>
|
|
||||||
<value>file:db/tables/scope.sql</value>
|
|
||||||
<value>file:db/tables/userinfo.sql</value>
|
|
||||||
<value>file:db/tables/whitelistedsite.sql</value>
|
|
||||||
<!-- Preloaded data -->
|
|
||||||
<value>classpath:test-data.sql</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
<property name="dateConversionPatterns">
|
|
||||||
<map>
|
|
||||||
<entry key="yyyy/mm/dd hh24:mi:ss" value="yyy/MM/dd HH:mm:ss" />
|
|
||||||
<entry key="yyyy-mm-dd" value="yyyy-MM-dd" />
|
|
||||||
</map>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
|
|
||||||
<bean id="testKeystore" class="org.mitre.jwt.encryption.impl.KeyStore">
|
|
||||||
<constructor-arg name="location" value="file:src/test/resources/keystore.jks" />
|
|
||||||
<constructor-arg name="password" value="changeit" />
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="configBean" class="org.mitre.openid.connect.config.ConfigurationPropertiesBean">
|
|
||||||
<property name="issuer" value="http://localhost/" />
|
|
||||||
<property name="defaultJwtSigner" value="rsa1"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
</beans>
|
|
|
@ -1,5 +0,0 @@
|
||||||
INSERT INTO ADDRESS (ID, STREETADDRESS, LOCALITY, REGION, POSTALCODE, COUNTRY) VALUES (1, '7443 Et Road', 'Pass Christian', 'ID', '16183', 'Jordan');
|
|
||||||
INSERT INTO ADDRESS (ID, STREETADDRESS, LOCALITY, REGION, POSTALCODE, COUNTRY) VALUES (2, 'P.O. Box 893, 2523 Felis Rd.', 'New Kensington', 'NT', 'I5V 3Z7', 'Israel');
|
|
||||||
|
|
||||||
INSERT INTO event (ID, TIMESTAMP, TYPE) VALUES (1, '1970-01-05 19:00:00.0', 0);
|
|
||||||
INSERT INTO event (ID, TIMESTAMP, TYPE) VALUES (2, '1970-01-10 19:00:00.0', 1);
|
|
6
pom.xml
6
pom.xml
|
@ -184,12 +184,6 @@
|
||||||
<version>${org.springframework-version}</version>
|
<version>${org.springframework-version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.h2database</groupId>
|
|
||||||
<artifactId>h2</artifactId>
|
|
||||||
<version>1.3.154</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cglib</groupId>
|
<groupId>cglib</groupId>
|
||||||
<artifactId>cglib</artifactId>
|
<artifactId>cglib</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue