Skip to content

Instantly share code, notes, and snippets.

@lucassha
Created March 14, 2019 00:15
Show Gist options
  • Save lucassha/953c262fde0f74926ebb1e8a1e108802 to your computer and use it in GitHub Desktop.
Save lucassha/953c262fde0f74926ebb1e8a1e108802 to your computer and use it in GitHub Desktop.
Allow Local URLs UrlValidator
======================================================
Testing SCHEMES below:
Testing scheme for url: http://www.google.com. Expected to return TRUE
false
Testing scheme for url: http://www.facebook.com. Expected to return TRUE
false
Testing scheme for url: ftp://www.amazon.com. Expected to return TRUE
false
Testing scheme for url: http:www.google.com. Expected to return FALSE
false
Testing scheme for url: http:/www.facebook.com. Expected to return FALSE
false
======================================================
Testing AUTHORITY below:
Testing authority for url: 1.2.3.4. Expected to return TRUE
false
Testing authority for url: www.google.com. Expected to return TRUE
false
Testing authority for url: www.twitter.com. Expected to return TRUE
false
Testing authority for url: . Expected to return FALSE
false
Testing authority for url: http://www.google.com. Expected to return FALSE
false
======================================================
Testing PORTS below:
Testing ports for url: http://www.google.com:80. Expected to return TRUE
false
Testing ports for url: http://twitter.com:8080. Expected to return TRUE
false
Testing ports for url: http://facebook.com:1234. Expected to return TRUE
false
Testing ports for url: http://www.google.com. Expected to return TRUE
false
Testing ports for url: http://www.google.com:0. Expected to return FALSE
false
Testing ports for url: http://www.google.com:abc. Expected to return FALSE
false
Testing ports for url: http://www.google.com:-12. Expected to return FALSE
false
======================================================
Testing PATHS below:
Testing paths for URL: http://www.google.com/hi. Expected to return TRUE
false
Testing paths for URL: http://www.google.com/123abc. Expected to return TRUE
false
Testing paths for URL: http://www.google.com/123/abc. Expected to return TRUE
false
Testing paths for URL: http://www.google.com. Expected to return TRUE
false
Testing paths for URL: http://www.google.com/..//hi. Expected to return FALSE
false
Testing paths for URL: http://www.google.com/123///abc. Expected to return FALSE
false
Testing paths for URL: http://www.google.com/../. Expected to return FALSE
false
======================================================
Testing QUERIES below:
Testing queries for URL: http://www.google.com?name=roonilwazlib. Expected to return TRUE
false
Testing queries for URL: http://www.google.com?class=361&stateofmind=dazedandconfused. Expected to return TRUE
false
Testing queries for URL: http://www.google.com. Expected to return TRUE
false
Testing queries for URL: http://www.google.com????name=kyle. Expected to return FALSE
false
Testing queries for URL: http://www.google.com?name=. Expected to return FALSE
false
Testing queries for URL: http://www.google.com??. Expected to return FALSE
false
Ending --- Allow Local URLs UrlValidator
======================================================
======================================================
Testing URL Port Validation
======================================================
URL: http://www.oregonstate.edu:80 Expected: VALID Result: INVALID FAILED
URL: http://www.oregonstate.edu:65535 Expected: VALID Result: INVALID FAILED
URL: http://www.oregonstate.edu Expected: VALID Result: VALID PASSED
URL: http://www.oregonstate.edu:-1 Expected: INVALID Result: INVALID PASSED
URL: http://www.oregonstate.edu:65636 Expected: INVALID Result: INVALID PASSED
URL: http://www.oregonstate.edu:65a Expected: INVALID Result: INVALID PASSED
======================================================
Testing URL Authority Validation
======================================================
URL: http://go.com Expected: VALID Result: VALID PASSED
URL: http://go.au Expected: VALID Result: VALID PASSED
URL: http://0.0.0.0 Expected: VALID Result: VALID PASSED
URL: http://255.255.255.255 Expected: VALID Result: VALID PASSED
URL: http://255.com Expected: VALID Result: VALID PASSED
URL: http://256.256.256.256 Expected: INVALID Result: VALID FAILED
URL: http://1.2.3.4.5 Expected: INVALID Result: VALID FAILED
URL: http://1.2.3.4. Expected: INVALID Result: VALID FAILED
URL: http://1.2.3 Expected: INVALID Result: VALID FAILED
URL: http://.1.2.3.4 Expected: INVALID Result: VALID FAILED
URL: http://go.a Expected: INVALID Result: VALID FAILED
URL: http://go.ala Expected: INVALID Result: VALID FAILED
URL: http://go.laa Expected: INVALID Result: VALID FAILED
URL: http://aaa. Expected: INVALID Result: VALID FAILED
URL: http://.aaa Expected: INVALID Result: VALID FAILED
URL: http://aaa Expected: INVALID Result: VALID FAILED
URL: http:// Expected: INVALID Result: VALID FAILED
======================================================
Testing URL Query Validation
======================================================
URL: http://www.oregonstate.edu?action=view Expected: VALID Result: VALID PASSED
URL: http://www.oregonstate.edu?action=edit&mode=up Expected: VALID Result: VALID PASSED
URL: http://www.oregonstate.edu Expected: VALID Result: VALID PASSED
======================================================
Testing URL Path Validation
======================================================
URL: http://www.oregonstate.edu/test1 Expected: VALID Result: VALID PASSED
URL: http://www.oregonstate.edu/t123 Expected: VALID Result: VALID PASSED
URL: http://www.oregonstate.edu/$23 Expected: VALID Result: VALID PASSED
URL: http://www.oregonstate.edu/test1/ Expected: VALID Result: INVALID FAILED
URL: http://www.oregonstate.edu Expected: VALID Result: VALID PASSED
URL: http://www.oregonstate.edu/test1/file Expected: VALID Result: INVALID FAILED
URL: http://www.oregonstate.edu/.. Expected: INVALID Result: INVALID PASSED
URL: http://www.oregonstate.edu/../ Expected: INVALID Result: INVALID PASSED
URL: http://www.oregonstate.edu/..//file Expected: INVALID Result: INVALID PASSED
URL: http://www.oregonstate.edu/test1//file Expected: INVALID Result: INVALID PASSED
======================================================
Testing URL Scheme Validation
======================================================
URL: http://www.oregonstate.edu Expected: VALID Result: INVALID FAILED
URL: https://www.oregonstate.edu Expected: VALID Result: INVALID FAILED
URL: ftp://www.oregonstate.edu Expected: VALID Result: INVALID FAILED
URL: h3t://www.oregonstate.edu Expected: VALID Result: INVALID FAILED
URL: 3ht://www.oregonstate.edu Expected: INVALID Result: INVALID PASSED
URL: http:/www.oregonstate.edu Expected: INVALID Result: INVALID PASSED
URL: http:www.oregonstate.edu Expected: INVALID Result: INVALID PASSED
URL: http/www.oregonstate.edu Expected: INVALID Result: INVALID PASSED
URL: ://www.oregonstate.edu Expected: INVALID Result: INVALID PASSED
======================================================
Testing random components of the ResultPair[] objects concatenated together
======================================================
======================================================
Created the following random URL string: http:255.com/../?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http:/go.a1a:80/t123?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http://go.com:65535/test1?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http://go.a:80/..?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: h3t://go.com:80/test1/file?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ://256.256.256.256:-1/test1/?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http/aaa.:65636/$23?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: h3t://1.2.3.4.5:0/test1/file?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: h3t://go.au:65636/test1/?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: h3t://go.au:65636/test1/file?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: 3ht://.1.2.3.4:80/..?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ://1.2.3:65535/test1/file?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ://0.0.0.0/$23?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: h3t://255.255.255.255:80/test1?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http:/1.2.3.4.5/..//file?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: 3ht://go.a1a:-1/$23?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: 3ht://255.com:65535/$23?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http://1.2.3.4.5:65535/t123?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ftp://1.2.3.4.:65636/../?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ://www.google.com/..?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http:/1.2.3:80/..//file?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http://0.0.0.0:80/test1/?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ftp://256.256.256.256:65535?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ftp://aaa/test1/file?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ftp://go.au:65535/..?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: h3t://256.256.256.256:65636/..?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: h3t://go.a1a:-1/..?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http:aaa.:0/test1/file?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ftp://256.256.256.256:0/..//file?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ://256.256.256.256:-1/t123?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ftp://go.au/test1/?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: h3t://1.2.3.4./../?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: 3ht://aaa.:-1/../?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: 3ht://www.google.com:65535/..?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http/255.255.255.255:65636/..?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http:256.256.256.256:0?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: 3ht://www.google.com:-1?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http/www.google.com:80/../?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: h3t://go.a:-1/test1/?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ftp://go.a1a/../?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: h3t://256.256.256.256:0/..//file?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http/www.google.com:0/$23?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: 3ht://1.2.3:80/..?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ://1.2.3:65535?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: h3t://1.2.3.4./test1/?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http:/aaa.:0/../?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: 3ht://go.a:65535/test1?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http/1.2.3.4.5:0/..?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: ://aaa.:65636/..//file?action=view
Calling isValid() function:
URL is NOT VALID
======================================================
Created the following random URL string: http/256.256.256.256:80/..//file?action=edit&mode=up
Calling isValid() function:
URL is NOT VALID
Process finished with exit code 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment