Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@ name: Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.13', 'pypy-3.10']
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
python-version: ['3.13', '3.14', 'pypy-3.10']
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
Expand Down
1,900 changes: 1,021 additions & 879 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["poetry-core>=1.6.0","poetry-dynamic-versioning>=0.22.0"]
requires = ["poetry-core>=2.4.0","poetry-dynamic-versioning>=1.10.0"]
build-backend = "poetry_dynamic_versioning.backend"

[tool.poetry-dynamic-versioning]
Expand Down Expand Up @@ -30,6 +30,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
packages = [{ include = "ndn", from = "src" }]
include = [{ path = "tests", format = "sdist" }]
Expand All @@ -40,16 +41,15 @@ include = [{ path = "tests", format = "sdist" }]

[tool.poetry.dependencies]
python = "^3.10"
pycryptodomex = "^3.21.0"
pygtrie = "^2.5.0"
aenum = "^3.1.15"
lark = "^1.2.2"
aiohttp = "^3.10.9"
aiohttp = "^3.14.3,<4.0.0"
lark = "^1.3.1,<2.0.0"
pycryptodomex = "^3.23.0,<4.0.0"
pygtrie = "^2.5.0,<3.0.0"

# Extra dependencies [dev]
pytest = { version = ">=7.1.2,<10.0.0", optional = true }
pytest-cov = { version = "^4.1.0", optional = true }
flake8 = { version = "^6.1.0", optional = true }
pytest = { version = ">=9.1.1,<10.0.0", optional = true }
pytest-cov = { version = "^4.1.0,<5.0.0", optional = true }
flake8 = { version = "^6.1.0,<7.0.0", optional = true }

# Extra dependencies [docs]
Sphinx = { version = "^7.1.2", optional = true }
Expand Down
1 change: 0 additions & 1 deletion src/ndn/bin/tools/cmd_compile_lvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import lark
from ndn.app_support.light_versec import compile_lvs, SemanticError
from ndn.app_support.light_versec.binary import *


def add_parser(subparsers):
Expand Down
7 changes: 2 additions & 5 deletions src/ndn/platform/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# limitations under the License.
# -----------------------------------------------------------------------------
import os
import aenum
import socket
import asyncio as aio
import ctypes as c
Expand All @@ -27,9 +26,7 @@ class SockaddrUn(c.Structure):
_fields_ = [("sun_family", c.c_ushort), ("sun_path", c.c_char * 108)]


aenum.extend_enum(socket.AddressFamily, "AF_UNIX", 1)
AF_UNIX = socket.AddressFamily(1)
NULL = 0
AF_UNIX = int(getattr(socket.AddressFamily, "AF_UNIX", 1))


class Cng:
Expand Down Expand Up @@ -105,7 +102,7 @@ def default_tpm_paths(self):
@staticmethod
def _iocp_connect(proactor, conn, address):
# _overlapped.WSAConnect(conn.fileno(), address)
addr = SockaddrUn(AF_UNIX.value, address.encode() + b"\0")
addr = SockaddrUn(AF_UNIX, address.encode() + b"\0")
winsock = c.windll.ws2_32
winsock.connect(conn.fileno(), addr, 110)

Expand Down
1 change: 0 additions & 1 deletion src/ndn/security/signer/ed25519_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# limitations under the License.
# -----------------------------------------------------------------------------
from Cryptodome.PublicKey import ECC
from Cryptodome.Hash import SHA512
from Cryptodome.Signature import eddsa
from ...encoding import Signer, SignatureType, KeyLocator, NonStrictName, VarBinaryStr, BinaryStr

Expand Down
2 changes: 1 addition & 1 deletion src/ndn/security/validator/known_key_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# limitations under the License.
# -----------------------------------------------------------------------------
import abc
from Cryptodome.Hash import SHA256, HMAC, SHA512
from Cryptodome.Hash import SHA256, HMAC
from Cryptodome.PublicKey import ECC, RSA
from Cryptodome.Signature import DSS, pkcs1_15, eddsa
from ...encoding import FormalName, BinaryStr, NonStrictName, SignaturePtrs, Name, SignatureType
Expand Down
42 changes: 21 additions & 21 deletions tests/integration/app_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,29 @@ async def validator(_name, _sig, _context) -> types.ValidResult:
return types.ValidResult.FAIL

async def face_proc(self, face: DummyFace):
await face.consume_output(b'\x05\x1b\x07\x10\x08\x03not\x08\timportant\n\x04\x00\x00\x00\x00\x0c\x01\x05')
await face.consume_output(b'\x05\x1b\x07\x10\x08\x03not\x08\timportant\n\x04\x00\x00\x00\x00\x0c\x01\xfa')
await face.input_packet(b'\x06\x1d\x07\x10\x08\x03not\x08\timportant\x14\x03\x18\x01\x00\x15\x04test')

async def app_main(self):
with pytest.raises(types.ValidationFailure) as e:
await self.app.express('/not/important', validator=self.validator, nonce=0, lifetime=5)
await self.app.express('/not/important', validator=self.validator, nonce=0, lifetime=250)
assert e.value.name == enc.Name.from_str('/not/important')
assert e.value.content == b'test'
assert e.value.result == types.ValidResult.FAIL


class TestInterestCanBePrefix(NDNAppTestSuite):
async def face_proc(self, face: DummyFace):
await face.consume_output(b'\x05\x0a\x07\x05\x08\x03not\x0c\x01\x05'
b'\x05\x0c\x07\x05\x08\x03not\x21\x00\x0c\x01\x05'
b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\x05')
await face.consume_output(b'\x05\x0a\x07\x05\x08\x03not\x0c\x01\xfa'
b'\x05\x0c\x07\x05\x08\x03not\x21\x00\x0c\x01\xfa'
b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\xfa')
await face.input_packet(b'\x06\x1d\x07\x10\x08\x03not\x08\timportant\x14\x03\x18\x01\x00\x15\x04test')
await aio.sleep(0.1)
await aio.sleep(0.4)

async def app_main(self):
future1 = self.app.express('/not', app.pass_all, nonce=None, lifetime=5, can_be_prefix=False)
future2 = self.app.express('/not', app.pass_all, nonce=None, lifetime=5, can_be_prefix=True)
future3 = self.app.express('/not/important', app.pass_all, nonce=None, lifetime=5, can_be_prefix=False)
future1 = self.app.express('/not', app.pass_all, nonce=None, lifetime=250, can_be_prefix=False)
future2 = self.app.express('/not', app.pass_all, nonce=None, lifetime=250, can_be_prefix=True)
future3 = self.app.express('/not/important', app.pass_all, nonce=None, lifetime=250, can_be_prefix=False)
name2, content2, _ = await future3
name1, content1, _ = await future2
with pytest.raises(types.InterestTimeout):
Expand All @@ -142,7 +142,7 @@ async def app_main(self):
class TestRoute(NDNAppTestSuite):
async def face_proc(self, face: DummyFace):
await face.ignore_output(0)
await face.input_packet(b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\x05')
await face.input_packet(b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\xfa')
await face.consume_output(b'\x06\x24\x07\x10\x08\x03not\x08\timportant\x14\x03\x18\x01\x00\x15\x04test'
b'\x16\x03\x1b\x01\xc8\x17\x00')

Expand All @@ -164,7 +164,7 @@ async def face_proc(self, face: DummyFace):
await face.input_packet(b'\x05`\x072\x08\x03not\x08\timportant'
b'\x02 E\x8a\xeaxI}[\xb1\xcd\xf0\x01\xbe'
b'\xdb\xe9\x03\x085\xb1g+K\xa8jK,\xd0\xad'
b')\x07\x83\x96\xbb\x0c\x01\x05$\x00,\x03'
b')\x07\x83\x96\xbb\x0c\x01\xfa$\x00,\x03'
b'\x1b\x01\x00. !\x93!zG[%\xcfs\xe89\\\x8f'
b'^\xd3\xa4\xb9\x13\xaa\x7f\xa6?\xd7\x13aVyS\xdc\x1dW\xea')
await aio.sleep(0.005)
Expand All @@ -178,14 +178,14 @@ def on_interest(_name, _app_param, _reply: app.ReplyFunc, _context):
class TestRoute2(NDNAppTestSuite):
async def face_proc(self, face: DummyFace):
await face.ignore_output(0)
await face.input_packet(b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\x05')
await face.input_packet(b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\xfa')
await face.consume_output(b'\x06\x24\x07\x10\x08\x03not\x08\timportant\x14\x03\x18\x01\x00\x15\x04test'
b'\x16\x03\x1b\x01\xc8\x17\x00')

async def app_main(self):
@self.app.route('/not')
def on_interest(name, _app_param, reply: app.ReplyFunc, context):
assert context['raw_packet'] == b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\x05'
assert context['raw_packet'] == b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\xfa'
assert not context['sig_ptrs'].signature_info
reply(self.app.make_data(name, b'test', signer=sec.NullSigner()))

Expand Down Expand Up @@ -213,14 +213,14 @@ class TestCongestionMark(NDNAppTestSuite):
async def face_proc(self, face: DummyFace):
await face.ignore_output(0)
await face.input_packet(b'\x64\x1e\xfd\x03\x40\x01\x01\x50\x17'
b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\x05')
b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\xfa')
await face.consume_output(b'\x06\x24\x07\x10\x08\x03not\x08\timportant\x14\x03\x18\x01\x00\x15\x04test'
b'\x16\x03\x1b\x01\xc8\x17\x00', timeout=0.5)

async def app_main(self):
@self.app.route('/not')
def on_interest(name, _app_param, reply: app.ReplyFunc, context):
assert context['raw_packet'] == b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\x05'
assert context['raw_packet'] == b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\xfa'
assert not context['sig_ptrs'].signature_info
reply(self.app.make_data(name, b'test', signer=sec.NullSigner()))

Expand All @@ -230,21 +230,21 @@ async def face_proc(self, face: DummyFace):
await face.consume_output(b'\x05\x2d\x07\x28\x08\x04test\x01\x20'
b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
b'\x0c\x01\x05'
b'\x0c\x01\xfa'
b'\x05\x2d\x07\x28\x08\x04test\x01\x20'
b'\x54\x88\xf2\xc1\x1b\x56\x6d\x49\xe9\x90\x4f\xb5\x2a\xa6\xf6\xf9'
b'\xe6\x6a\x95\x41\x68\x10\x9c\xe1\x56\xee\xa2\xc9\x2c\x57\xe4\xc2'
b'\x0c\x01\x05')
b'\x0c\x01\xfa')
await face.input_packet(b'\x06\x13\x07\x06\x08\x04test\x14\x03\x18\x01\x00\x15\x04test')
await aio.sleep(0.1)
await aio.sleep(0.4)

async def app_main(self):
fut1 = self.app.express(
'/test/sha256digest=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',
validator=app.pass_all, nonce=None, lifetime=5)
validator=app.pass_all, nonce=None, lifetime=250)
fut2 = self.app.express(
'/test/sha256digest=5488f2c11b566d49e9904fb52aa6f6f9e66a954168109ce156eea2c92c57e4c2',
validator=app.pass_all, nonce=None, lifetime=5)
validator=app.pass_all, nonce=None, lifetime=250)
name2, content2, _ = await fut2
with pytest.raises(types.InterestTimeout):
await fut1
Expand All @@ -256,7 +256,7 @@ class TestPitToken(NDNAppTestSuite):
async def face_proc(self, face: DummyFace):
await face.ignore_output(0)
await face.input_packet(b'\x64\x1f\x62\x04\x01\x02\x03\x04\x50\x17'
b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\x05')
b'\x05\x15\x07\x10\x08\x03not\x08\timportant\x0c\x01\xfa')
await face.consume_output(b'\x64\x2e\x62\x04\x01\x02\x03\x04\x50\x26'
b'\x06\x24\x07\x10\x08\x03not\x08\timportant\x14\x03\x18\x01\x00\x15\x04test'
b'\x16\x03\x1b\x01\xc8\x17\x00')
Expand Down
4 changes: 3 additions & 1 deletion tests/misc/light_versec_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ def test_signing_suggest():
checker = Checker(compile_lvs(lvs), DEFAULT_USER_FNS)
assert checker.suggest("/article/eco/day1", keychain) == ny_author_cert_name

keychain.shutdown()

@staticmethod
def test_complicated_redef():
lvs = r'''
Expand Down Expand Up @@ -414,4 +416,4 @@ def test_complicated_redef():
assert not checker.check('/ndn/ucla/%C1.Operator/13/KEY/2/ndn/3', '/yoursunny/ucla/KEY/2/ndn/3')
# But super-zone can sign sub-zone
assert checker.check('/ndn/ucla/cs/%C1.Operator/13/KEY/2/ndn/3', '/ndn/ucla/KEY/2/ndn/3')
assert not checker.check('/ndn/ucla/cs/%C1.Operator/13/KEY/2/ndn/3', '/ndn/ucla/ee/KEY/2/ndn/3')
assert not checker.check('/ndn/ucla/cs/%C1.Operator/13/KEY/2/ndn/3', '/ndn/ucla/ee/KEY/2/ndn/3')
Loading