Exemplo n.º 1
0
 def test_directives_correct_no_dupes(self):
     """
     Tests that a Listen object properly returns a unique directive if the same directive is
     added multiple times.
     """
     directive = { "signature" : "a:0.0.0.0:80:a.b.c:/"}
     handle_listen = Listen(**{})
     for i in range(10):
         handle_listen.directives = directive
     self.assertEqual(len(handle_listen.directives), 1)
     self.assertEqual(directive, handle_listen.directives[0])
     del handle_listen
Exemplo n.º 2
0
 def test_directives_correct_no_dupes(self):
     """
     Tests that a Listen object properly returns a unique directive if the same directive is
     added multiple times.
     """
     directive = {"signature": "a:0.0.0.0:80:a.b.c:/"}
     handle_listen = Listen(**{})
     for i in range(10):
         handle_listen.directives = directive
     self.assertEqual(len(handle_listen.directives), 1)
     self.assertEqual(directive, handle_listen.directives[0])
     del handle_listen
Exemplo n.º 3
0
 def test_build_correct_no_dupes(self):
     """
     Tests that the _build method properly generate a unique ServerName object if we try to
     resolve the same server name twice.
     """
     handle_listen = Listen(**{})
     server_name = "a.b.c.d"
     directive = {"signature" : "a:0.0.0.0:80:%s:/" % (server_name)}
     for _ in range(10):
         handle_listen.directives = directive
     self.assertEqual(len(handle_listen.server_names.keys()), 1)
     self.assertEqual(list(handle_listen.server_names.keys())[0], server_name)
     del handle_listen
Exemplo n.º 4
0
 def test_build_correct(self):
     """
     Tests that the _build method properly turns the directives into unique ServerName objects.
     """
     handle_listen = Listen(**{})
     directives = [
                     { "signature" : "a:0.0.0.0:80:a.b.c.d:/"},
                     { "signature" : "a:0.0.0.0:8080:aa.bb.cc.dd:/"},
                     ]
     for directive in directives:
         handle_listen.directives = directive
     self.assertEqual(len(handle_listen.server_names.keys()), 2)
     del handle_listen
Exemplo n.º 5
0
 def test_build_correct_no_dupes(self):
     """
     Tests that the _build method properly generate a unique ServerName object if we try to
     resolve the same server name twice.
     """
     handle_listen = Listen(**{})
     server_name = "a.b.c.d"
     directive = {"signature": "a:0.0.0.0:80:%s:/" % (server_name)}
     for _ in range(10):
         handle_listen.directives = directive
     self.assertEqual(len(handle_listen.server_names.keys()), 1)
     self.assertEqual(
         list(handle_listen.server_names.keys())[0], server_name)
     del handle_listen
Exemplo n.º 6
0
 def test_is_valid_correct_invalid_location(self):
     """
     Tests that the is_valid property correctly returns False if any of its ServerNames is
     invalid.
     """
     directives = [
                     { "signature" : "container1:0.0.0.0:80:a.b.c:/location1/"},
                     { "signature" : "container2:0.0.0.0:80:a.b.c:/location1/"}
                     ]
     handle_listen = Listen(**{})
     for directive in directives:
         handle_listen.directives = directive  
     self.assertFalse(handle_listen.is_valid)
     del handle_listen
Exemplo n.º 7
0
 def test_is_valid_correct(self):
     """
     Tests that the is_valid property correctly returns True if all the ServerName objects
     associated to a Listen instance are valid.
     """
     directives = [
                     { "signature" : "container1:0.0.0.0:80:a.b.c:/location1/"},
                     { "signature" : "container1:0.0.0.0:80:a.b.c:/location2/"}
                     ]
     handle_listen = Listen(**{})
     for directive in directives:
         handle_listen.directives = directive  
     self.assertTrue(handle_listen.is_valid)
     del handle_listen
Exemplo n.º 8
0
 def test_is_valid_correct_invalid_location(self):
     """
     Tests that the is_valid property correctly returns False if any of its ServerNames is
     invalid.
     """
     directives = [{
         "signature": "container1:0.0.0.0:80:a.b.c:/location1/"
     }, {
         "signature": "container2:0.0.0.0:80:a.b.c:/location1/"
     }]
     handle_listen = Listen(**{})
     for directive in directives:
         handle_listen.directives = directive
     self.assertFalse(handle_listen.is_valid)
     del handle_listen
Exemplo n.º 9
0
 def test_is_valid_correct(self):
     """
     Tests that the is_valid property correctly returns True if all the ServerName objects
     associated to a Listen instance are valid.
     """
     directives = [{
         "signature": "container1:0.0.0.0:80:a.b.c:/location1/"
     }, {
         "signature": "container1:0.0.0.0:80:a.b.c:/location2/"
     }]
     handle_listen = Listen(**{})
     for directive in directives:
         handle_listen.directives = directive
     self.assertTrue(handle_listen.is_valid)
     del handle_listen
Exemplo n.º 10
0
 def test_directives_correct(self):
     """
     Tests that a Listen object properly returns the directives that were assigned to it.
     """
     directives = [
                     { "signature" : "a:0.0.0.0:80:a.b.c:/"},
                     { "signature" : "a:0.0.0.0:8080:a.b.c:/"}
                     ]
     handle_listen = Listen(**{})
     for directive in directives:
         handle_listen.directives = directive
     self.assertEqual(len(handle_listen.directives), 2)
     for directive, expected_directive in zip(handle_listen.directives, directives):
         self.assertEqual(directive, expected_directive)
     del handle_listen
Exemplo n.º 11
0
 def test_directives_correct(self):
     """
     Tests that a Listen object properly returns the directives that were assigned to it.
     """
     directives = [{
         "signature": "a:0.0.0.0:80:a.b.c:/"
     }, {
         "signature": "a:0.0.0.0:8080:a.b.c:/"
     }]
     handle_listen = Listen(**{})
     for directive in directives:
         handle_listen.directives = directive
     self.assertEqual(len(handle_listen.directives), 2)
     for directive, expected_directive in zip(handle_listen.directives,
                                              directives):
         self.assertEqual(directive, expected_directive)
     del handle_listen
Exemplo n.º 12
0
 def test_build_correct(self):
     """
     Tests that the _build method properly turns the directives into unique ServerName objects.
     """
     handle_listen = Listen(**{})
     directives = [
         {
             "signature": "a:0.0.0.0:80:a.b.c.d:/"
         },
         {
             "signature": "a:0.0.0.0:8080:aa.bb.cc.dd:/"
         },
     ]
     for directive in directives:
         handle_listen.directives = directive
     self.assertEqual(len(handle_listen.server_names.keys()), 2)
     del handle_listen