1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
6 # <sales@bestpractical.com>
8 # (Except where explicitly superseded by other copyright notices)
13 # This work is made available to you under the terms of Version 2 of
14 # the GNU General Public License. A copy of that license should have
15 # been provided with this software, but in any event can be snarfed
18 # This work is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 # 02110-1301 or visit their web page on the internet at
27 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 # CONTRIBUTION SUBMISSION POLICY:
32 # (The following paragraph is not intended to limit the rights granted
33 # to you to modify and distribute this software under the terms of
34 # the GNU General Public License and is only of importance to you if
35 # you choose to contribute your changes and enhancements to the
36 # community by submitting them to Best Practical Solutions, LLC.)
38 # By intentionally submitting any modifications, corrections or
39 # derivatives to this work, or any other work intended for use with
40 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 # you are the copyright holder for those contributions and you grant
42 # Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 # royalty-free, perpetual, license to use, copy, create derivative
44 # works based on those contributions, and sublicense and distribute
45 # those contributions and any derivatives thereof.
47 # END BPS TAGGED BLOCK }}}
53 package RT::Test::SMIME;
56 use base qw(RT::Test);
57 use File::Temp qw(tempdir);
62 my $t = $class->builder;
64 RT::Test::plan( skip_all => 'openssl executable is required.' )
65 unless RT::Test->find_executable('openssl');
68 $class->SUPER::import(%args);
71 Principal => 'Everyone',
72 Right => ['CreateTicket', 'ShowTicket', 'SeeQueue', 'ReplyToTicket', 'ModifyTicket'],
75 $class->export_to_level(1);
78 sub bootstrap_more_config {
83 $self->SUPER::bootstrap_more_config($handle, $args, @_);
85 my $openssl = $self->find_executable('openssl');
87 my $keyring = $self->keyring_path;
90 my $ca = $self->key_path("demoCA", "cacert.pem");
93 Set(\%GnuPG, Enable => 0);
97 'root\@example.com' => '123456',
98 'sender\@example.com' => '123456',
100 OpenSSL => q{$openssl},
101 Keyring => q{$keyring},
104 Set(\@MailPlugins => qw(Auth::MailFrom Auth::Crypt));
110 return File::Spec->catfile( RT::Test->temp_directory, "smime" );
115 my $keys = RT::Test::get_abs_relocatable_dir(
116 (File::Spec->updir()) x 2,
119 return File::Spec->catfile( $keys => @_ ),
124 return RT::Test::get_abs_relocatable_dir(
125 (File::Spec->updir()) x 2,
126 qw(data smime mails),
135 my $path = RT::Test::find_relocatable_path( 'data', 'smime', 'keys' );
136 die "can't find the dir where smime keys are stored"
139 my $keyring = RT->Config->Get('SMIME')->{'Keyring'};
140 die "SMIME keyring '$keyring' doesn't exist"
141 unless $keyring && -e $keyring;
143 $key .= ".pem" unless $key =~ /\.(pem|crt|key)$/;
145 my $content = RT::Test->file_content( [ $path, $key ] );
148 my ($status, $msg) = $user->SetSMIMECertificate( $content );
149 die "Couldn't set CF: $msg" unless $status;
151 my $keyring = RT->Config->Get('SMIME')->{'Keyring'};
152 die "SMIME keyring '$keyring' doesn't exist"
153 unless $keyring && -e $keyring;
155 open my $fh, '>:raw', File::Spec->catfile($keyring, $key)
156 or die "can't open file: $!";