Python 3 library and CLI application for SporeStack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.2 KiB

  1. from . import api_client
  2. import pytest
  3. def test_validate_validate_use_tor_proxy():
  4. assert api_client.validate_use_tor_proxy(True) is True
  5. assert api_client.validate_use_tor_proxy(False) is True
  6. assert api_client.validate_use_tor_proxy("auto") is True
  7. with pytest.raises(ValueError):
  8. api_client.validate_use_tor_proxy("some string")
  9. with pytest.raises(ValueError):
  10. api_client.validate_use_tor_proxy(1)
  11. with pytest.raises(ValueError):
  12. api_client.validate_use_tor_proxy(0)
  13. def test_is_onion_url():
  14. onion_url = "http://spore64i5sofqlfz5gq2ju4msgzojjwifls7"
  15. onion_url += "rok2cti624zyq3fcelad.onion/v2/"
  16. assert api_client.is_onion_url(onion_url) is True
  17. # This is a good, unusual test.
  18. onion_url = "https://www.facebookcorewwwi.onion/"
  19. assert api_client.is_onion_url(onion_url) is True
  20. assert api_client.is_onion_url("http://domain.com") is False
  21. assert api_client.is_onion_url("domain.com") is False
  22. assert api_client.is_onion_url("http://onion.domain.com/.onion/") is False
  23. assert api_client.is_onion_url("http://me.me/file.onion/") is False
  24. assert api_client.is_onion_url("http://me.me/file.onion") is False