diff options
author | Olof Johansson <olof.johansson@axis.com> | 2016-04-01 17:01:48 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-04-03 15:53:44 +0100 |
commit | 2c722e227f3ff482566aac6c10de26b4909d34d6 (patch) | |
tree | 64b9fd51495496a11320ea09b2b06f2bc9b4a2a7 /bitbake/lib/bb/tests | |
parent | cf6d12d1910572447686c95c7d0949ab47804852 (diff) | |
download | poky-2c722e227f3ff482566aac6c10de26b4909d34d6.tar.gz |
bitbake: tests/fetch.py: Improve unit tests for trusted network check
The tests were skipped when running without network even though they
didn't require network. This commit also adds a test case for URLs with
ports in them (the ports should not be considered when doing trusted
network checks).
(Bitbake rev: 77747de6b20538063eef3b188489a35bef225359)
Signed-off-by: Olof Johansson <olof.johansson@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 77 |
1 files changed, 42 insertions, 35 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 29d8999bdd..4ba688bfea 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -611,42 +611,49 @@ class FetcherNetworkTest(FetcherTest): | |||
611 | os.chdir(os.path.dirname(self.unpackdir)) | 611 | os.chdir(os.path.dirname(self.unpackdir)) |
612 | fetcher.unpack(self.unpackdir) | 612 | fetcher.unpack(self.unpackdir) |
613 | 613 | ||
614 | def test_trusted_network(self): | ||
615 | # Ensure trusted_network returns False when the host IS in the list. | ||
616 | url = "git://Someserver.org/foo;rev=1" | ||
617 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org someserver.org server2.org server3.org") | ||
618 | self.assertTrue(bb.fetch.trusted_network(self.d, url)) | ||
619 | |||
620 | def test_wild_trusted_network(self): | ||
621 | # Ensure trusted_network returns true when the *.host IS in the list. | ||
622 | url = "git://Someserver.org/foo;rev=1" | ||
623 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org *.someserver.org server2.org server3.org") | ||
624 | self.assertTrue(bb.fetch.trusted_network(self.d, url)) | ||
625 | |||
626 | def test_prefix_wild_trusted_network(self): | ||
627 | # Ensure trusted_network returns true when the prefix matches *.host. | ||
628 | url = "git://git.Someserver.org/foo;rev=1" | ||
629 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org *.someserver.org server2.org server3.org") | ||
630 | self.assertTrue(bb.fetch.trusted_network(self.d, url)) | ||
631 | |||
632 | def test_two_prefix_wild_trusted_network(self): | ||
633 | # Ensure trusted_network returns true when the prefix matches *.host. | ||
634 | url = "git://something.git.Someserver.org/foo;rev=1" | ||
635 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org *.someserver.org server2.org server3.org") | ||
636 | self.assertTrue(bb.fetch.trusted_network(self.d, url)) | ||
637 | |||
638 | def test_untrusted_network(self): | ||
639 | # Ensure trusted_network returns False when the host is NOT in the list. | ||
640 | url = "git://someserver.org/foo;rev=1" | ||
641 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org server2.org server3.org") | ||
642 | self.assertFalse(bb.fetch.trusted_network(self.d, url)) | ||
643 | |||
644 | def test_wild_untrusted_network(self): | ||
645 | # Ensure trusted_network returns False when the host is NOT in the list. | ||
646 | url = "git://*.someserver.org/foo;rev=1" | ||
647 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org server2.org server3.org") | ||
648 | self.assertFalse(bb.fetch.trusted_network(self.d, url)) | ||
649 | 614 | ||
615 | class TrustedNetworksTest(FetcherTest): | ||
616 | def test_trusted_network(self): | ||
617 | # Ensure trusted_network returns False when the host IS in the list. | ||
618 | url = "git://Someserver.org/foo;rev=1" | ||
619 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org someserver.org server2.org server3.org") | ||
620 | self.assertTrue(bb.fetch.trusted_network(self.d, url)) | ||
621 | |||
622 | def test_wild_trusted_network(self): | ||
623 | # Ensure trusted_network returns true when the *.host IS in the list. | ||
624 | url = "git://Someserver.org/foo;rev=1" | ||
625 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org *.someserver.org server2.org server3.org") | ||
626 | self.assertTrue(bb.fetch.trusted_network(self.d, url)) | ||
627 | |||
628 | def test_prefix_wild_trusted_network(self): | ||
629 | # Ensure trusted_network returns true when the prefix matches *.host. | ||
630 | url = "git://git.Someserver.org/foo;rev=1" | ||
631 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org *.someserver.org server2.org server3.org") | ||
632 | self.assertTrue(bb.fetch.trusted_network(self.d, url)) | ||
633 | |||
634 | def test_two_prefix_wild_trusted_network(self): | ||
635 | # Ensure trusted_network returns true when the prefix matches *.host. | ||
636 | url = "git://something.git.Someserver.org/foo;rev=1" | ||
637 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org *.someserver.org server2.org server3.org") | ||
638 | self.assertTrue(bb.fetch.trusted_network(self.d, url)) | ||
639 | |||
640 | def test_port_trusted_network(self): | ||
641 | # Ensure trusted_network returns True, even if the url specifies a port. | ||
642 | url = "git://someserver.org:8080/foo;rev=1" | ||
643 | self.d.setVar("BB_ALLOWED_NETWORKS", "someserver.org") | ||
644 | self.assertTrue(bb.fetch.trusted_network(self.d, url)) | ||
645 | |||
646 | def test_untrusted_network(self): | ||
647 | # Ensure trusted_network returns False when the host is NOT in the list. | ||
648 | url = "git://someserver.org/foo;rev=1" | ||
649 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org server2.org server3.org") | ||
650 | self.assertFalse(bb.fetch.trusted_network(self.d, url)) | ||
651 | |||
652 | def test_wild_untrusted_network(self): | ||
653 | # Ensure trusted_network returns False when the host is NOT in the list. | ||
654 | url = "git://*.someserver.org/foo;rev=1" | ||
655 | self.d.setVar("BB_ALLOWED_NETWORKS", "server1.org server2.org server3.org") | ||
656 | self.assertFalse(bb.fetch.trusted_network(self.d, url)) | ||
650 | 657 | ||
651 | class URLHandle(unittest.TestCase): | 658 | class URLHandle(unittest.TestCase): |
652 | 659 | ||