Skip to content

Instantly share code, notes, and snippets.

@lopnor
Created March 4, 2009 13:59
Show Gist options
  • Save lopnor/73845 to your computer and use it in GitHub Desktop.
Save lopnor/73845 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use utf8;
use Test::More tests => 8;
use Digest::SHA1 qw(sha1_base64);
BEGIN { use_ok 'Test::WWW::Mechanize::Catalyst', 'MyApp' }
BEGIN { use_ok 'MyApp::Controller::Admin' }
BEGIN { use_ok 'MyApp::Schema' }
BEGIN { use_ok 'MyApp::Util::ConfigLoader' }
my $config = MyApp::Util::ConfigLoader->load;
my $schema = MyApp::Schema->connect(
@{ $config->{'Model::DBIC'}->{connect_info} }
);
my $salt = $config->{'Plugin::Authentication'}{realms}{members}{credential}{password_pre_salt};
my $account_info = {
mail => 'test+'.time.'@soffritto.org',
password => 'hogehoge',
};
my $member = $schema->resultset('Member')->create(
{
mail => $account_info->{mail},
password => sha1_base64($salt . $account_info->{password}),
nickname => 'test user '.scalar localtime,
}
);
$member->add_to_roles({role => 'admin'});
my $mech = Test::WWW::Mechanize::Catalyst->new;
$mech->get_ok('/admin');
like $mech->title, qr/ログイン/;
$mech->submit_form_ok(
{
form_number => 1,
fields => $account_info,
}
);
like $mech->title, qr/管理画面/;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment