Commit 794f2225 authored by Florian Vessaz's avatar Florian Vessaz

Fix tests

parent a3c9b0ef
......@@ -11,7 +11,7 @@ lib/GnuGeneration/Group.pm
lib/GnuGeneration/LDAP.pm
lib/GnuGeneration/Member.pm
lib/mail.pm
lib/main.pm
lib/members.pm
lib/PasswordToken.pm
Makefile.PL
MANIFEST
......
......@@ -10,7 +10,7 @@ $eumm_version =~ s/_//;
WriteMakefile(
NAME => 'GnuGeneration::MemberManagement',
AUTHOR => q{Florian Vessaw <florian.vessaz@epfl.ch>},
VERSION_FROM => 'lib/main.pm',
VERSION_FROM => 'lib/members.pm',
ABSTRACT => 'Webapp for GNU Generation members management',
($eumm_version >= 6.3001
? ('LICENSE'=> 'perl')
......
#!/usr/bin/env perl
use Dancer;
use main;
use members;
members::setup(
config->{ldap_admin_dn},
config->{ldap_admin_password},
config->{ldap_url},
config->{tokens_db},
);
dance;
use Dancer ':syntax';
package members;
use strict;
use warnings 'FATAL' => 'all';
our $VERSION = '0.1';
use Dancer ':syntax';
use Email::Valid;
use PasswordToken;
use Data::Dumper;
......@@ -15,14 +17,6 @@ use PasswordToken;
use mail;
GnuGeneration::LDAP->credentials(
dn => config->{ldap_admin_dn},
password => config->{ldap_admin_password});
GnuGeneration::Member->ldap_url(config->{ldap_url});
PasswordToken->init(dbfile => config->{tokens_db});
my $hosts = {
"rainbowdash" => {
name => "rainbowdash.gnugen.ch",
......@@ -42,6 +36,18 @@ my $mailing_lists = {
my $shells = [ "/bin/bash", "/bin/fish", "/bin/zsh" ];
package members {
sub setup {
my ($ldap_dn, $ldap_password, $ldap_url, $dbfile) = @_;
GnuGeneration::LDAP->credentials(
dn => $ldap_dn,
password => $ldap_password,
);
GnuGeneration::Member->ldap_url($ldap_url);
PasswordToken->init(dbfile => $dbfile);
}
}
sub is_admin() {
my $is_admin = session 'admin';
return $is_admin if (defined $is_admin);
......
use Test::More tests => 1;
use strict;
use warnings;
use_ok 'main';
use Test::More tests => 1;
use Dancer ':tests';
use_ok 'members';
use Test::More tests => 2;
use strict;
use warnings;
# the order is important
use main;
use Dancer::Test;
use Test::More tests => 2;
use Dancer ':tests';
use members;
use Plack::Test;
use HTTP::Request::Common;
set apphandler => 'PSGI';
set log => 'error';
my $app = Dancer::Handler->psgi_app;
my $test = Plack::Test->create($app);
route_exists [GET => '/'], 'a route handler is defined for /';
response_status_is ['GET' => '/'], 200, 'response status is 200 for /';
my $res = $test->request(GET '/');
is($res->code, 302, '[GET /] successful');
is($res->header('location')->path, '/login', '[GET /] redirects to /login');
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment