summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2019-10-03 17:46:28 +0300
committerAndrei Belov <defan@nginx.com>2019-10-03 17:46:28 +0300
commit3dd3f861f4c3aa320aa137802f033f8f1fc7dc41 (patch)
tree357577c560920eb0f5837b7d073999f5c7a1a2cd /test
parent9de7aea721245cda9f079a2b29d8efaf99c440fd (diff)
parent59db9a3887211fccdaec04b7952ad0140090de22 (diff)
downloadunit-3dd3f861f4c3aa320aa137802f033f8f1fc7dc41.tar.gz
unit-3dd3f861f4c3aa320aa137802f033f8f1fc7dc41.tar.bz2
Merged with the default branch.
Diffstat (limited to '')
-rw-r--r--test/test_static.py24
-rw-r--r--test/unit/applications/lang/go.py30
-rw-r--r--test/unit/applications/lang/java.py8
3 files changed, 48 insertions, 14 deletions
diff --git a/test/test_static.py b/test/test_static.py
index 573669a3..4bdd83ed 100644
--- a/test/test_static.py
+++ b/test/test_static.py
@@ -1,4 +1,5 @@
import os
+import socket
import unittest
from unit.applications.proto import TestApplicationProto
@@ -169,6 +170,29 @@ class TestStatic(TestApplicationProto):
self.get(url='/ди ректория/фа йл')['body'], 'blah', 'dir name 2'
)
+ def test_static_unix_socket(self):
+ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ sock.bind(self.testdir + '/assets/unix_socket')
+
+ self.assertEqual(self.get(url='/unix_socket')['status'], 404, 'socket')
+
+ sock.close()
+
+ def test_static_unix_fifo(self):
+ os.mkfifo(self.testdir + '/assets/fifo')
+
+ self.assertEqual(self.get(url='/fifo')['status'], 404, 'fifo')
+
+ def test_static_symlink(self):
+ os.symlink(self.testdir + '/assets/dir', self.testdir + '/assets/link')
+
+ self.assertEqual(self.get(url='/dir')['status'], 301, 'dir')
+ self.assertEqual(self.get(url='/dir/file')['status'], 200, 'file')
+ self.assertEqual(self.get(url='/link')['status'], 301, 'symlink dir')
+ self.assertEqual(
+ self.get(url='/link/file')['status'], 200, 'symlink file'
+ )
+
def test_static_head(self):
resp = self.head(url='/')
self.assertEqual(resp['status'], 200, 'status')
diff --git a/test/unit/applications/lang/go.py b/test/unit/applications/lang/go.py
index 15ac1cd9..18345828 100644
--- a/test/unit/applications/lang/go.py
+++ b/test/unit/applications/lang/go.py
@@ -12,7 +12,8 @@ class TestApplicationGo(TestApplicationProto):
go_app = TestApplicationGo()
go_app.testdir = unit.testdir
- if go_app.prepare_env('empty', 'app').returncode == 0:
+ proc = go_app.prepare_env('empty', 'app')
+ if proc and proc.returncode == 0:
cls.available['modules']['go'] = []
return unit if not complete_check else unit.complete()
@@ -23,18 +24,23 @@ class TestApplicationGo(TestApplicationProto):
env = os.environ.copy()
env['GOPATH'] = self.pardir + '/go'
- process = Popen(
- [
- 'go',
- 'build',
- '-o',
- self.testdir + '/go/' + name,
- self.current_dir + '/go/' + script + '/' + name + '.go',
- ],
- env=env,
- )
- process.communicate()
+ try:
+ process = Popen(
+ [
+ 'go',
+ 'build',
+ '-o',
+ self.testdir + '/go/' + name,
+ self.current_dir + '/go/' + script + '/' + name + '.go',
+ ],
+ env=env,
+ )
+
+ process.communicate()
+
+ except:
+ return None
return process
diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py
index 40bf3662..bcf87f59 100644
--- a/test/unit/applications/lang/java.py
+++ b/test/unit/applications/lang/java.py
@@ -63,8 +63,12 @@ class TestApplicationJava(TestApplicationProto):
]
javac.extend(src)
- process = Popen(javac)
- process.communicate()
+ try:
+ process = Popen(javac)
+ process.communicate()
+
+ except:
+ self.fail('Cann\'t run javac process.')
self._load_conf(
{