This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
174 additions
and
5 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,120 @@ | ||
# Standard Library | ||
from json import dumps | ||
|
||
# 3rd Party | ||
from preggy import expect | ||
|
||
# Fastlane | ||
from fastlane.worker.docker.api import validate_hostname | ||
|
||
|
||
def test_validate_hostname1(): | ||
expect(validate_hostname("example.com")).to_be_false() | ||
|
||
|
||
def test_validate_hostname2(): | ||
expect(validate_hostname("example.com/")).to_be_false() | ||
|
||
|
||
def test_validate_hostname3(): | ||
expect(validate_hostname("example.com:abcd")).to_be_false() | ||
|
||
|
||
def test_validate_hostname4(): | ||
expect(validate_hostname("example.com:1234")).to_be_true() | ||
|
||
|
||
def test_add_to_blacklist1(client): | ||
"""Test adding to blacklist without payload returns 400""" | ||
with client.application.app_context(): | ||
resp = client.post( | ||
f"/docker-executor/blacklist" | ||
) | ||
expect(resp.status_code).to_equal(400) | ||
|
||
|
||
def test_add_to_blacklist2(client): | ||
"""Test adding to blacklist without host on payload returns 400""" | ||
|
||
with client.application.app_context(): | ||
resp = client.post( | ||
f"/docker-executor/blacklist", | ||
data=dumps({ | ||
"myparam": "abc" | ||
}) | ||
) | ||
expect(resp.status_code).to_equal(400) | ||
|
||
|
||
def test_add_to_blacklist3(client): | ||
"""Test adding to blacklist with valid host on payload returns 400""" | ||
|
||
with client.application.app_context(): | ||
resp = client.post( | ||
f"/docker-executor/blacklist", | ||
data=dumps({ | ||
"host": "example.com" | ||
}) | ||
) | ||
expect(resp.status_code).to_equal(400) | ||
|
||
|
||
def test_add_to_blacklist4(client): | ||
"""Test adding to blacklist with valid host on payload returns 200""" | ||
|
||
with client.application.app_context(): | ||
resp = client.post( | ||
f"/docker-executor/blacklist", | ||
data=dumps({ | ||
"host": "example.com:1234" | ||
}) | ||
) | ||
expect(resp.status_code).to_equal(200) | ||
|
||
|
||
def test_remove_from_blacklist1(client): | ||
"""Test adding to blacklist without payload returns 400""" | ||
with client.application.app_context(): | ||
resp = client.delete( | ||
f"/docker-executor/blacklist" | ||
) | ||
expect(resp.status_code).to_equal(400) | ||
|
||
|
||
def test_remove_from_blacklist2(client): | ||
"""Test adding to blacklist without host on payload returns 400""" | ||
|
||
with client.application.app_context(): | ||
resp = client.delete( | ||
f"/docker-executor/blacklist", | ||
data=dumps({ | ||
"myparam": "abc" | ||
}) | ||
) | ||
expect(resp.status_code).to_equal(400) | ||
|
||
|
||
def test_remove_from_blacklist3(client): | ||
"""Test adding to blacklist with valid host on payload returns 400""" | ||
|
||
with client.application.app_context(): | ||
resp = client.delete( | ||
f"/docker-executor/blacklist", | ||
data=dumps({ | ||
"host": "example.com" | ||
}) | ||
) | ||
expect(resp.status_code).to_equal(400) | ||
|
||
|
||
def test_remove_from_blacklist4(client): | ||
"""Test adding to blacklist with valid host on payload returns 200""" | ||
|
||
with client.application.app_context(): | ||
resp = client.delete( | ||
f"/docker-executor/blacklist", | ||
data=dumps({ | ||
"host": "example.com:1234" | ||
}) | ||
) | ||
expect(resp.status_code).to_equal(200) |