summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2019-09-24 16:13:20 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2019-09-24 16:13:20 +0300
commit702ca2b85396d35a0c0e037852854fd9901e2a09 (patch)
tree6fac22e3b4ba247ef68d187e1726437f044e4d86
parent93ead878105883dd5c70751f06dae13ef7a13c03 (diff)
downloadunit-702ca2b85396d35a0c0e037852854fd9901e2a09.tar.gz
unit-702ca2b85396d35a0c0e037852854fd9901e2a09.tar.bz2
Tests: static tests with file system objects.
-rw-r--r--test/test_static.py24
1 files changed, 24 insertions, 0 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')