RT 4.0.22
[freeside.git] / rt / t / security / CVE-2011-2084-transactions.t
1 use strict;
2 use warnings;
3
4 use RT::Test tests => undef;
5
6 # A privileged user, but with no privs
7 my $bad = RT::Test->load_or_create_user(
8     Name => 'testing',
9     EmailAddress => 'test@example.com',
10     Password => 'password',
11 );
12 ok( $bad, "Got a user object back" );
13 ok( $bad->id, "Successfully created a user" );
14
15
16 # A ticket CF
17 my $obj = RT::Test->load_or_create_custom_field(
18     Name  => "Private CF",
19     Type  => "Freeform",
20     Queue => 0,
21 );
22
23 my ($t) = RT::Test->create_tickets( {},
24     { Subject => 'Testing' }
25 );
26 ok($t->id, "Created a ticket");
27
28 # Add a txn on it
29 my ($cfid) = $t->AddCustomFieldValue(
30     Field => $obj->Id,
31     Value => "hidden-value"
32 );
33 ok($cfid, "Got CF id $cfid");
34 my $update_id = $t->Transactions->Last->Id;
35
36 # Somebody else shouldn't be able to see the old and new values
37 my ($base, $m) = RT::Test->started_ok;
38 $m->post_ok("$base/REST/1.0/transaction/$update_id", [
39     user    => 'testing',
40     pass    => 'password',
41     format  => 'l',
42 ]);
43 $m->content_lacks("hidden-value");
44
45 # Make a transaction on a user
46 my $root = RT::Test->load_or_create_user( Name => "root" );
47 $root->SetHomePhone("hidden-value");
48 $update_id = $root->Transactions->Last->Id;
49
50 # Which should also be hidden from random privileged users
51 $m->post_ok("$base/REST/1.0/transaction/$update_id", [
52     user    => 'testing',
53     pass    => 'password',
54     format  => 'l',
55 ]);
56 $m->content_lacks("hidden-value");
57
58 undef $m;
59 done_testing;