1#!perl
2use warnings;
3use strict;
4use Test::More;
5use CGI::Fast;
6use File::Temp;
7
8my $OS;
9
10unless ($OS = $^O) {
11	require Config;
12	$OS = $Config::Config{'osname'};
13}
14
15if ( $OS =~ /mswin|cygwin/i ) {
16	plan skip_all => "valid on unix-y servers only";
17}
18
19{ no warnings 'redefine'; sub FCGI::Accept ($) {} }
20
21my $fh = File::Temp->new;
22my $f  = $fh->filename;
23undef( $fh );
24
25import CGI::Fast socket_path => $f;
26ok( !-e $f, 'socket not exists' );
27CGI::Fast->new();
28ok( -e $f, 'socket was created' );
29is( 0777 & (stat $f)[2], 0777 & ~umask, 'socket has default perms' );
30unlink $f;
31undef $CGI::Fast::Ext_Request;
32
33import CGI::Fast socket_perm => 0777;
34ok( !-e $f, 'socket not exists' );
35CGI::Fast->new();
36ok( -e $f, 'socket was created' );
37is( 0777 & (stat $f)[2], 0777, 'socket has given perms' );
38unlink $f;
39undef $CGI::Fast::Ext_Request;
40
41import CGI::Fast socket_perm => 0777;
42ok( !-e $f, 'socket not exists' );
43$ENV{FCGI_SOCKET_PERM} = 0666;
44CGI::Fast->new();
45ok( -e $f, 'socket was created' );
46is( 0777 & (stat $f)[2], 0666, '$FCGI_SOCKET_PERM has higher priority' );
47unlink $f;
48undef $CGI::Fast::Ext_Request;
49
50done_testing();
51