示例#1
0
        async def go():
            endpoint = BMAEndpoint("", "124.2.2.1", "", 9092)
            session = aiohttp.ClientSession()

            api = API(endpoint.conn_handler(session), )
            self.assertEqual(api.reverse_url("http", "/test/url"), "http://124.2.2.1:9092/test/url")
            await session.close()
示例#2
0
 async def go():
     endpoint = BMAEndpoint("", "", "2001:0db8:0000:85a3:0000:0000:ac1f:8001", 9092)
     session = aiohttp.ClientSession()
     api = API(endpoint.conn_handler(session), )
     self.assertEqual(api.reverse_url("http", "/test/url"),
                      "http://[2001:0db8:0000:85a3:0000:0000:ac1f:8001]:9092/test/url")
     await session.close()
示例#3
0
        async def go():
            endpoint = BMAEndpoint("", "124.2.2.1", "", 9092)
            session = aiohttp.ClientSession()

            api = API(endpoint.conn_handler(session), )
            self.assertEqual(api.reverse_url("http", "/test/url"),
                             "http://124.2.2.1:9092/test/url")
            await session.close()
示例#4
0
 async def go():
     endpoint = BMAEndpoint("test.com", "124.2.2.1",
                            "2001:0db8:0000:85a3:0000:0000:ac1f:8001 ",
                            9092)
     session = aiohttp.ClientSession()
     api = API(endpoint.conn_handler(session), )
     self.assertEqual(api.reverse_url("http", "/test/url"),
                      "http://test.com:9092/test/url")
     await session.close()
示例#5
0
 async def go():
     _, port, _ = await self.create_server("GET", "/network/peering",
                                           handler)
     with self.assertRaises(jsonschema.exceptions.ValidationError):
         client = Client(BMAEndpoint("127.0.0.1", "", "", port))
         await client(network.peering)
     await client.close()
示例#6
0
 async def go():
     _, port, _ = await self.create_server("GET", "/network/ws2p/heads",
                                           handler)
     with self.assertRaises(jsonschema.ValidationError):
         client = Client(BMAEndpoint("127.0.0.1", "", "", port))
         await client(network.ws2p_heads)
     await client.close()
 async def go():
     _, port, _ = await self.create_server("GET", "/blockchain/with/tx",
                                           handler)
     with self.assertRaises(jsonschema.exceptions.ValidationError):
         client = Client(BMAEndpoint("127.0.0.1", "", "", port))
         await client(tx)
     await client.close()
示例#8
0
 async def go():
     _, port, url = await self.create_server(
         'GET', '/wot/certified-by/pubkey', handler)
     with self.assertRaises(jsonschema.exceptions.ValidationError):
         client = Client(BMAEndpoint("127.0.0.1", "", "", port))
         await client(certified_by, 'pubkey')
     await client.close()
示例#9
0
 async def go():
     _, port, url = await self.create_server('GET', '/wot/members',
                                             handler)
     with self.assertRaises(jsonschema.exceptions.ValidationError):
         client = Client(BMAEndpoint("127.0.0.1", "", "", port))
         await client(members)
     await client.close()
示例#10
0
 async def go():
     _, port, _ = await self.create_server(
         "GET", "/wot/certifiers-of/pubkey", handler
     )
     with self.assertRaises(jsonschema.exceptions.ValidationError):
         client = Client(BMAEndpoint("127.0.0.1", "", "", port))
         await client(certifiers_of, "pubkey")
     await client.close()
示例#11
0
 async def go():
     _, port, url = await self.create_server('GET',
                                             '/blockchain/with/certs',
                                             handler)
     with self.assertRaises(jsonschema.exceptions.ValidationError):
         client = Client(BMAEndpoint("127.0.0.1", "", "", port))
         await client(certifications)
     await client.close()
示例#12
0
 async def go():
     _, port, url = await self.create_server(
         'GET', '/blockchain/memberships'
         '/8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU', handler)
     with self.assertRaises(jsonschema.exceptions.ValidationError):
         client = Client(BMAEndpoint("127.0.0.1", "", "", port))
         await client(memberships,
                      "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU")
     await client.close()
 async def go():
     _, port, _ = await self.create_server(
         "GET",
         "/blockchain/hardship/8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU",
         handler,
     )
     with self.assertRaises(jsonschema.exceptions.ValidationError):
         client = Client(BMAEndpoint("127.0.0.1", "", "", port))
         await client(hardship,
                      "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU")
     await client.close()
示例#14
0
 async def go():
     _, port, url = await self.create_server('GET', '/tx/history/pubkey/blocks/0/100', handler)
     with self.assertRaises(jsonschema.exceptions.ValidationError):
         client = Client(BMAEndpoint("127.0.0.1", "", "", port))
         await client(blocks, 'pubkey', 0, 100)
     await client.close()
示例#15
0
        "500488-0001980F9AD959F86210BF872FE44A31ACF1596EB6D2D444CC9FD30EFE423541",
        "signature":
        "RbqCnXhPoq714z9gJFiJ7b8VE9sOQt1oWsDYIvAVoxhklDCYptFmGrrofR76dj9pThcaPDnwt93Is79nQ91ICg==",
        "endpoints": [
            "BASIC_MERKLED_API g1-test.duniter.org 443",
            "WS2P 96675302 g1-test.duniter.org 443 ws2p",
        ],
    }


@pytest.mark.parametrize(
    "bma_endpoint",
    [
        "BASIC_MERKLED_API g1-test.duniter.org 443",
        "BMAS g1-test.duniter.org 443",
        BMAEndpoint.from_inline("BASIC_MERKLED_API g1-test.duniter.org 443"),
        SecuredBMAEndpoint.from_inline("BMAS g1-test.duniter.org 443"),
    ],
)
@pytest.mark.asyncio
async def test_generate_ws2p_endpoint(bma_endpoint, monkeypatch):
    monkeypatch.setattr("duniterpy.api.bma.network.peering", peering_ws2p)
    reference_ep = WS2PEndpoint.from_inline(
        "WS2P 96675302 g1-test.duniter.org 443 ws2p")
    generated_ep = await generate_ws2p_endpoint(bma_endpoint)
    assert reference_ep == generated_ep


@pytest.mark.parametrize("bma_endpoint", ["BMAS g1-test.duniter.org 443"])
@pytest.mark.asyncio
async def test_generate_ws2p_endpoint_no_ws2p(bma_endpoint, monkeypatch):