-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into docs/Issue-204
- Loading branch information
Showing
10 changed files
with
150 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
# This workflow will install Python dependencies, run tests and lint | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Check Black | ||
|
||
on: | ||
|
@@ -16,7 +13,7 @@ jobs: | |
strategy: | ||
matrix: | ||
python-version: | ||
- "3.8" | ||
- "3.12" | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
# This workflow will install Python dependencies, run tests and lint | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Check flake8 | ||
|
||
on: | ||
|
@@ -16,7 +13,7 @@ jobs: | |
strategy: | ||
matrix: | ||
python-version: | ||
- "3.8" | ||
- "3.12" | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
# This workflow will install Python dependencies, run tests and lint | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Check pytest | ||
name: Run pytest | ||
|
||
on: | ||
push: | ||
|
@@ -11,12 +8,11 @@ on: | |
pull_request: | ||
|
||
jobs: | ||
check-pytest: | ||
run-pytest: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: | ||
- "3.8" | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
from pyVoIP.VoIP import call, phone, status | ||
|
||
CallState = call.CallState | ||
VoIPCall = call.VoIPCall | ||
PhoneStatus = status.PhoneStatus | ||
VoIPPhone = phone.VoIPPhone | ||
__all__ = ["call", "phone", "status"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
from pyVoIP.networking.nat import NAT, NATError | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"nat_settings,test_against,expected", | ||
[ | ||
# Test Remote Host | ||
( | ||
{ | ||
"bind_ip": "10.0.0.4", | ||
"network": "10.0.0.0/24", | ||
"remote_hostname": "example.com", | ||
}, | ||
"8.8.8.8", | ||
"example.com", | ||
), | ||
( | ||
{ | ||
"bind_ip": "10.0.0.4", | ||
"network": "10.0.0.0/24", | ||
"remote_hostname": "example.com", | ||
}, | ||
"example.org", | ||
"example.com", | ||
), | ||
( | ||
{ | ||
"bind_ip": "10.0.0.4", | ||
"network": "10.0.0.0/24", | ||
"remote_hostname": "example.com", | ||
}, | ||
"10.0.1.1", | ||
"example.com", | ||
), | ||
( | ||
{ | ||
"bind_ip": "10.0.0.4", | ||
"network": "10.0.0.0/16", | ||
"remote_hostname": "example.com", | ||
}, | ||
"10.1.0.1", | ||
"example.com", | ||
), | ||
# Test Remote Host with Bind 0.0.0.0 | ||
( | ||
{ | ||
"bind_ip": "0.0.0.0", | ||
"network": "10.0.0.0/24", | ||
"hostname": "10.0.0.4", | ||
"remote_hostname": "example.com", | ||
}, | ||
"8.8.8.8", | ||
"example.com", | ||
), | ||
( | ||
{ | ||
"bind_ip": "0.0.0.0", | ||
"network": "10.0.0.0/24", | ||
"hostname": "10.0.0.4", | ||
"remote_hostname": "example.com", | ||
}, | ||
"10.0.1.1", | ||
"example.com", | ||
), | ||
( | ||
{ | ||
"bind_ip": "0.0.0.0", | ||
"network": "10.0.0.0/16", | ||
"hostname": "10.0.0.4", | ||
"remote_hostname": "example.com", | ||
}, | ||
"10.1.0.1", | ||
"example.com", | ||
), | ||
# Test Local Host | ||
( | ||
{ | ||
"bind_ip": "10.0.0.4", | ||
"network": "10.0.0.0/24", | ||
}, | ||
"10.0.0.10", | ||
"10.0.0.4", | ||
), | ||
( | ||
{ | ||
"bind_ip": "10.0.0.4", | ||
"network": "10.0.0.0/16", | ||
}, | ||
"10.0.1.1", | ||
"10.0.0.4", | ||
), | ||
( | ||
{ | ||
"bind_ip": "10.0.0.4", | ||
"network": "10.0.0.0/8", | ||
}, | ||
"10.1.1.1", | ||
"10.0.0.4", | ||
), | ||
# Test Local Host with Bind 0.0.0.0 | ||
( | ||
{ | ||
"bind_ip": "0.0.0.0", | ||
"network": "10.0.0.0/24", | ||
"hostname": "10.0.0.4", | ||
}, | ||
"10.0.0.10", | ||
"10.0.0.4", | ||
), | ||
( | ||
{ | ||
"bind_ip": "0.0.0.0", | ||
"network": "10.0.0.0/16", | ||
"hostname": "10.0.0.4", | ||
}, | ||
"10.0.1.1", | ||
"10.0.0.4", | ||
), | ||
( | ||
{ | ||
"bind_ip": "0.0.0.0", | ||
"network": "10.0.0.0/8", | ||
"hostname": "10.0.0.4", | ||
}, | ||
"10.1.1.10", | ||
"10.0.0.4", | ||
), | ||
], | ||
) | ||
def test_nat(nat_settings, test_against, expected): | ||
nat = NAT(**nat_settings) | ||
assert nat.get_host(test_against) == expected | ||
|
||
|
||
def test_nat_error(): | ||
nat = NAT("192.168.0.5", "192.168.0.0/24") | ||
with pytest.raises(NATError): | ||
nat.get_host("google.com") |