package IdPAccountManager::TestAccount; use IdPAccountManager::Data::Testaccount; use IdPAccountManager::Data::Testaccount::Manager; use IdPAccountManager::Tools; use IdPAccountManager::Conf; use Moose; use Moose::Util::TypeConstraints; subtype 'entityid', as 'Str', where { /^(urn:|http(s)?\:\/\/)/ }, message { "$_ is not a valide entityid"}; has 'account_profile' => (is => 'rw', isa => 'Str', required => 1); has 'sp_entityid' => (is => 'rw', isa => 'entityid', required => 1, ); has 'id' => (is => 'ro', isa => 'Int', required => 0, ); has 'user_password' => (is => 'ro', isa => 'Str', required => 0, ); sub BUILD { my $self = shift; my $args = shift; my $testaccount_db = IdPAccountManager::Data::Testaccount->new('account_profile' => $args->{'account_profile'}, 'sp_entityid' => $args->{'sp_entityid'}, 'user_password' => &IdPAccountManager::Tools::generate_password(), 'creation_date' => time, 'expiration_date' => time + ($IdPAccountManager::Conf::global{'accounts_validity_period'} * 3600 * 24)); $testaccount_db->save(); ## TODO : update IdP conf file; given the account profile } ## list all test accounts ## Class method sub list_test_accounts { my %args = @_; my $all = IdPAccountManager::Data::Testaccount::Manager->get_testaccounts(%args); return $all; } #before 'new' => sub { print "about to call new\n"; }; 1; # Magic true value required at end of module __END__ =head1 NAME IdPAccountManager::TestAccount - Manage test user accounts for the Test Identity Provider =head1 SYNOPSIS =head1 DESCRIPTION =head1 SUBROUTINES/METHODS =head1 AUTHOR Olivier Salaün (olivier.salaun@renater.fr)