Skip to content
Snippets Groups Projects
Select Git revision
  • ddeacc9d1f908e41057cead31530f9d4cc0cefd6
  • master default protected
  • 3-regression-l-onglet-network-reste-vide
  • v1.7.5 protected
  • v1.7.4 protected
  • v1.7.3 protected
  • v1.7.2 protected
  • v1.7.1 protected
  • v1.7.0 protected
  • v1.6.31 protected
  • v1.6.30 protected
  • v1.6.29 protected
  • v1.6.28 protected
  • v1.6.27 protected
  • v1.6.26 protected
  • v1.6.25 protected
  • v1.6.24 protected
  • v1.6.23 protected
  • v1.6.22 protected
  • v1.6.21 protected
  • v1.6.20 protected
  • v1.6.19 protected
  • v1.6.18 protected
23 results

index.js

Blame
  • test_endpoints.py 4.08 KiB
    # Copyright  2014-2021 Vincent Texier <vit@free.fr>
    #
    # DuniterPy is free software: you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation, either version 3 of the License, or
    # (at your option) any later version.
    #
    # DuniterPy is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    import unittest
    
    from duniterpy.api import endpoint
    
    
    class TestEndpoint(unittest.TestCase):
        def test_gva(self):
            endpoint_str = "GVA test.domain.com 127.0.0.1 2001:0db8:0000:85a3:0000:0000:ac1f:8001 10902 gva"
    
            gva_endpoint = endpoint.GVAEndpoint.from_inline(endpoint_str)
    
            self.assertEqual(gva_endpoint.flags, "")
            self.assertEqual(gva_endpoint.server, "test.domain.com")
            self.assertEqual(gva_endpoint.ipv4, "127.0.0.1")
            self.assertEqual(gva_endpoint.ipv6, "2001:0db8:0000:85a3:0000:0000:ac1f:8001")
            self.assertEqual(gva_endpoint.port, 10902)
            self.assertEqual(gva_endpoint.path, "gva")
    
            self.assertEqual(gva_endpoint.inline(), endpoint_str)
    
            endpoint_str = "GVA S test.domain.com 10902 gva"
    
            gva_endpoint = endpoint.GVAEndpoint.from_inline(endpoint_str)
    
            self.assertEqual(gva_endpoint.flags, "S")
            self.assertEqual(gva_endpoint.server, "test.domain.com")
            self.assertEqual(gva_endpoint.ipv4, None)
            self.assertEqual(gva_endpoint.ipv6, None)
            self.assertEqual(gva_endpoint.port, 10902)
            self.assertEqual(gva_endpoint.path, "gva")
    
            self.assertEqual(gva_endpoint.inline(), endpoint_str)
    
            endpoint_str = "GVA S xn--duniter.org 10902"
    
            gva_endpoint = endpoint.GVAEndpoint.from_inline(endpoint_str)
    
            self.assertEqual(gva_endpoint.flags, "S")
            self.assertEqual(gva_endpoint.server, "xn--duniter.org")
            self.assertEqual(gva_endpoint.ipv4, None)
            self.assertEqual(gva_endpoint.ipv6, None)
            self.assertEqual(gva_endpoint.port, 10902)
            self.assertEqual(gva_endpoint.path, "")
    
            self.assertEqual(gva_endpoint.inline(), endpoint_str)
    
        def test_gva_subscription(self):
            endpoint_str = "GVASUB test.domain.com 127.0.0.1 2001:0db8:0000:85a3:0000:0000:ac1f:8001 10902 gva"
    
            gvasub_endpoint = endpoint.GVASUBEndpoint.from_inline(endpoint_str)
    
            self.assertEqual(gvasub_endpoint.flags, "")
            self.assertEqual(gvasub_endpoint.server, "test.domain.com")
            self.assertEqual(gvasub_endpoint.ipv4, "127.0.0.1")
            self.assertEqual(
                gvasub_endpoint.ipv6, "2001:0db8:0000:85a3:0000:0000:ac1f:8001"
            )
            self.assertEqual(gvasub_endpoint.port, 10902)
            self.assertEqual(gvasub_endpoint.path, "gva")
    
            self.assertEqual(gvasub_endpoint.inline(), endpoint_str)
    
            endpoint_str = "GVASUB S test.domain.com 10902 gva"
    
            gvasub_endpoint = endpoint.GVASUBEndpoint.from_inline(endpoint_str)
    
            self.assertEqual(gvasub_endpoint.flags, "S")
            self.assertEqual(gvasub_endpoint.server, "test.domain.com")
            self.assertEqual(gvasub_endpoint.ipv4, None)
            self.assertEqual(gvasub_endpoint.ipv6, None)
            self.assertEqual(gvasub_endpoint.port, 10902)
            self.assertEqual(gvasub_endpoint.path, "gva")
    
            assert gvasub_endpoint.inline(), endpoint_str
    
        def test_gva_host_ipv4_mix_up(self):
            endpoint_str = "GVA S 127.0.0.1 443 gva"
            gva_endpoint = endpoint.GVAEndpoint.from_inline(endpoint_str)
            self.assertEqual(gva_endpoint.server, "")
            self.assertEqual(gva_endpoint.ipv4, "127.0.0.1")
    
        def test_bmas_host_ipv4_mix_up(self):
            endpoint_str = "BMAS 127.0.0.1 443 bma"
            bmas_endpoint = endpoint.SecuredBMAEndpoint.from_inline(endpoint_str)
            self.assertEqual(bmas_endpoint.server, "")
            self.assertEqual(bmas_endpoint.ipv4, "127.0.0.1")