plan tests => 17;
- $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
$ENV{TESTAPP_CONFIG} = {
name => 'TestApp',
authentication => {
];
}
-use SetupDB;
-
use Catalyst::Test 'TestApp';
# log a user in
my $res = request('http://localhost/user_login?username=joeuser&password=hackme');
like( $res->content, qr/\$\Qc->model('Nonexistent::Class') did not return a resultset. Did you set user_model correctly?/, 'test for wrong user_class' );
}
-
-
-
-
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};
or plan skip_all =>
"DBIx::Class is required for this test";
- eval { require Catalyst::Plugin::Session;
+ eval { require Catalyst::Plugin::Session;
die unless $Catalyst::Plugin::Session::VERSION >= 0.02 }
or plan skip_all =>
"Catalyst::Plugin::Session >= 0.02 is required for this test";
plan tests => 8;
- $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
$ENV{TESTAPP_CONFIG} = {
name => 'TestApp',
authentication => {
];
}
-use SetupDB;
-
use Test::WWW::Mechanize::Catalyst 'TestApp';
my $m = Test::WWW::Mechanize::Catalyst->new;
$m->get_ok( 'http://localhost/get_session_user', undef, 'request ok' );
$m->content_is( '', "user's session deleted" );
}
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};
plan tests => 8;
- $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
-
$ENV{TESTAPP_CONFIG} = {
name => 'TestApp',
authentication => {
];
}
-use SetupDB;
-
use Catalyst::Test 'TestApp';
# test user's admin access
ok( my $res = request('http://localhost/user_login?username=nuffin&password=much&detach=is_admin_user'), 'request ok' );
is( $res->content, 'failed', 'user is not an admin and a user' );
}
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};
plan tests => 8;
- $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
-
$ENV{TESTAPP_CONFIG} = {
name => 'TestApp',
authentication => {
];
}
-use SetupDB;
-
use Catalyst::Test 'TestApp';
# test user's admin access
ok( my $res = request('http://localhost/user_login?username=joeuser&password=hackme&detach=is_admin_user'), 'request ok' );
is( $res->content, 'failed', 'user is not an admin and a user' );
}
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};
or plan skip_all =>
"DBIx::Class is required for this test";
- eval { require Catalyst::Plugin::Session;
+ eval { require Catalyst::Plugin::Session;
die unless $Catalyst::Plugin::Session::VERSION >= 0.02 }
or plan skip_all =>
"Catalyst::Plugin::Session >= 0.02 is required for this test";
plan tests => 8;
- $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
$ENV{TESTAPP_CONFIG} = {
name => 'TestApp',
authentication => {
];
}
-use SetupDB;
-
use Test::WWW::Mechanize::Catalyst 'TestApp';
my $m = Test::WWW::Mechanize::Catalyst->new;
$m->get_ok( 'http://localhost/get_session_user', undef, 'request ok' );
$m->content_is( '', "user's session deleted" );
}
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};
plan tests => 8;
- $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
-
$ENV{TESTAPP_CONFIG} = {
name => 'TestApp',
'Plugin::Authentication' => {
];
}
-use SetupDB;
-
use Catalyst::Test 'TestApp';
# test user's admin access
ok( my $res = request('http://localhost/user_login?username=nuffin&password=much&detach=is_admin_user'), 'request ok' );
is( $res->content, 'failed', 'user is not an admin and a user' );
}
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};
plan tests => 8;
- $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
-
$ENV{TESTAPP_CONFIG} = {
name => 'TestApp',
'Plugin::Authentication' => {
password_type => 'clear'
}
}
-
+
};
$ENV{TESTAPP_PLUGINS} = [
];
}
-use SetupDB;
-
use Catalyst::Test 'TestApp';
# test user's admin access
ok( my $res = request('http://localhost/user_login?username=joeuser&password=hackme&detach=is_admin_user'), 'request ok' );
is( $res->content, 'failed', 'user is not an admin and a user' );
}
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};
+++ /dev/null
-# create the database
-my $db_file = $ENV{TESTAPP_DB_FILE};
-unlink $db_file if -e $db_file;
-
-my $dbh = DBI->connect( "dbi:SQLite:$db_file" ) or die $DBI::errstr;
-my $sql = q{
- CREATE TABLE user (
- id INTEGER PRIMARY KEY,
- username TEXT,
- email TEXT,
- password TEXT,
- status TEXT,
- role_text TEXT,
- session_data TEXT
- );
- CREATE TABLE role (
- id INTEGER PRIMARY KEY,
- role TEXT
- );
- CREATE TABLE user_role (
- id INTEGER PRIMARY KEY,
- user INTEGER,
- roleid INTEGER
- );
-
- INSERT INTO user VALUES (1, 'joeuser', 'joeuser@nowhere.com', 'hackme', 'active', 'admin', NULL);
- INSERT INTO user VALUES (2, 'spammer', 'bob@spamhaus.com', 'broken', 'disabled', NULL, NULL);
- INSERT INTO user VALUES (3, 'jayk', 'j@cpants.org', 'letmein', 'active', NULL, NULL);
- INSERT INTO user VALUES (4, 'nuffin', 'nada@mucho.net', 'much', 'registered', 'user admin', NULL);
- INSERT INTO role VALUES (1, 'admin');
- INSERT INTO role VALUES (2, 'user');
- INSERT INTO user_role VALUES (1, 3, 1);
- INSERT INTO user_role VALUES (2, 3, 2);
- INSERT INTO user_role VALUES (3, 4, 2)
-};
-$dbh->do( $_ ) for split /;/, $sql;
-$dbh->disconnect;
\ No newline at end of file
use base qw/Catalyst::Model::DBIC::Schema/;
use strict;
-
-our $db_file = $ENV{TESTAPP_DB_FILE};
+my @deployment_statements = split /;/, q{
+ CREATE TABLE user (
+ id INTEGER PRIMARY KEY,
+ username TEXT,
+ email TEXT,
+ password TEXT,
+ status TEXT,
+ role_text TEXT,
+ session_data TEXT
+ );
+ CREATE TABLE role (
+ id INTEGER PRIMARY KEY,
+ role TEXT
+ );
+ CREATE TABLE user_role (
+ id INTEGER PRIMARY KEY,
+ user INTEGER,
+ roleid INTEGER
+ );
+
+ INSERT INTO user VALUES (1, 'joeuser', 'joeuser@nowhere.com', 'hackme', 'active', 'admin', NULL);
+ INSERT INTO user VALUES (2, 'spammer', 'bob@spamhaus.com', 'broken', 'disabled', NULL, NULL);
+ INSERT INTO user VALUES (3, 'jayk', 'j@cpants.org', 'letmein', 'active', NULL, NULL);
+ INSERT INTO user VALUES (4, 'nuffin', 'nada@mucho.net', 'much', 'registered', 'user admin', NULL);
+ INSERT INTO role VALUES (1, 'admin');
+ INSERT INTO role VALUES (2, 'user');
+ INSERT INTO user_role VALUES (1, 3, 1);
+ INSERT INTO user_role VALUES (2, 3, 2);
+ INSERT INTO user_role VALUES (3, 4, 2)
+};
__PACKAGE__->config(
schema_class => 'TestApp::Schema',
- connect_info => [ "dbi:SQLite:$db_file",
- '',
- '',
- { AutoCommit => 1 },
- ],
-
+ connect_info => [
+ "dbi:SQLite:dbname=:memory:",
+ '',
+ '',
+ { AutoCommit => 1 },
+ { on_connect_do => \@deployment_statements },
+ ],
);
# Load all of the classes