Skip to content

Commit

Permalink
SECOAUTH-61: allow for client details to be stored in db
Browse files Browse the repository at this point in the history
  • Loading branch information
stoicflame committed Jun 24, 2011
1 parent a9fb394 commit ec32d06
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
package org.springframework.security.oauth2.provider.token;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.SingleConnectionDataSource;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;

public class TestJdbcOAuth2ProviderTokenServices extends TestRandomValueOAuth2ProviderTokenServicesBase {
private JdbcOAuth2ProviderTokenServices oauth2ProviderTokenServices;
private EmbeddedDatabase db;

@Override
protected void setUp() throws Exception {
super.setUp();

Class.forName("org.hsqldb.jdbcDriver");
SingleConnectionDataSource dataSource = new SingleConnectionDataSource("jdbc:hsqldb:mem:lookupstrategytest", "sa", "", true);
dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
oauth2ProviderTokenServices = new JdbcOAuth2ProviderTokenServices(dataSource);
// creates a HSQL in-memory db populated from default scripts classpath:schema.sql and classpath:data.sql
db = new EmbeddedDatabaseBuilder().addDefaultScripts().build();
oauth2ProviderTokenServices = new JdbcOAuth2ProviderTokenServices(db);
oauth2ProviderTokenServices.afterPropertiesSet();
}

try {
jdbcTemplate.execute("drop table oauth_access_token");
}
catch (Exception e) {
// don't care
}

try {
jdbcTemplate.execute("drop table oauth_refresh_token");
}
catch (Exception e) {
// don't care
}

jdbcTemplate.execute("create table oauth_access_token (token_id VARCHAR(256), token LONGVARBINARY, authentication LONGVARBINARY, refresh_token VARCHAR(256))");
jdbcTemplate.execute("create table oauth_refresh_token (token_id VARCHAR(256), token LONGVARBINARY, authentication LONGVARBINARY)");
@Override
public void tearDown() throws Exception {
super.tearDown();
db.shutdown();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
package org.springframework.security.oauth2.provider.verification;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.SingleConnectionDataSource;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;

public class TestJdbcVerificationCodeServices extends TestVerificationCodeServicesBase {
private JdbcVerificationCodeServices verificationCodeServices;
private EmbeddedDatabase db;

@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();

Class.forName("org.hsqldb.jdbcDriver");
SingleConnectionDataSource dataSource = new SingleConnectionDataSource("jdbc:hsqldb:mem:lookupstrategytest", "sa", "", true);
dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
verificationCodeServices = new JdbcVerificationCodeServices(dataSource);
// creates a HSQL in-memory db populated from default scripts classpath:schema.sql and classpath:data.sql
db = new EmbeddedDatabaseBuilder().addDefaultScripts().build();
verificationCodeServices = new JdbcVerificationCodeServices(db);
verificationCodeServices.afterPropertiesSet();
}

try {
jdbcTemplate.execute("drop table oauth_code");
}
catch (Exception e) {
// don't care
}

jdbcTemplate.execute("create table oauth_code (code VARCHAR(256), authentication LONGVARBINARY)");
@Override
public void tearDown() throws Exception {
super.tearDown();
db.shutdown();
}

@Override
Expand Down

0 comments on commit ec32d06

Please sign in to comment.