Leser: 18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package MyApp::Test::Database::Live;
use strict;
use warnings;
use MyAppDB;
use MyApp::Model::MyAppDB;
use Directory::Scratch;
use YAML qw( DumpFile );
use FindBin qw( $Bin );
use Digest::SHA1 qw( sha1_hex );
use Catalyst::Test "MyApp";
use HTTP::Request;
use base 'Exporter';
our @EXPORT = qw /schema log_in /;
my $schema;
my $config;
BEGIN {
my $tmp = Directory::Scratch->new;
my $db = $tmp->touch('db');
my $dsn = "DBI:SQLite:$db";
$schema = MyAppDB->connect($dsn);
$schema->deploy;
$config = "$Bin/../myapp_Local.yml";
DumpFile($config, { 'MyApp::Model::MyAppDB' => { connect_info => [$dsn]}});
}
sub schema { $schema };
sub log_in {
my $mech = shift;
my $dummy = { 'Content-type' => 'application/json' };
my $person = schema()->resultset('MyAppDB::User')->create({
login => 'testuser',
password => sha1_hex('testing'),
mail => 'testuser@mydomain.de',
first_name => 'Max',
last_name => 'Mustermann',
company => 'MyCompany',
customer_id => 'custid',
});
my @ar;
push @ar, $dummy;
my $req = HTTP::Request->new('POST', 'http://localhost/rest/login/login', \@ar, '{ "login": "testuser", "password": "testing"}'. "\n" );
request($req);
}
END { unlink $config };
1;
1
2
my $obj = '{ "login": "testuser@skytel.de", "password": "testing"}' . "\n";
my $dummy = [ 'Content-type' => 'application/json', 'Content-Length' => length($obj) ];
my $req = HTTP::Request->new('POST', 'http://localhost:3000/rest/login/login', $dummy, $obj);