mirror of
https://github.com/Facepunch/sbox-public.git
synced 2025-12-31 10:28:22 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using System;
|
|
|
|
namespace Misc
|
|
{
|
|
[TestClass]
|
|
public class WebSurfaceTests
|
|
{
|
|
[TestMethod]
|
|
[DataRow( "http://google.com", true )]
|
|
[DataRow( "https://google.com", true )]
|
|
[DataRow( "https://api.google.com", true )]
|
|
[DataRow( "https://yahoo.com", true )]
|
|
[DataRow( "http://127.0.0.1", false )]
|
|
[DataRow( "http://127.0.0.1:80", false )]
|
|
[DataRow( "http://127.0.0.1:443", false )]
|
|
[DataRow( "http://127.0.0.1:8080", false )]
|
|
[DataRow( "http://127.0.0.1:8443", false )]
|
|
[DataRow( "http://127.0.0.1:1337", false )]
|
|
[DataRow( "https://localhost/", false )]
|
|
[DataRow( "https://localhost:80/", false )]
|
|
[DataRow( "https://localhost:443/", false )]
|
|
[DataRow( "https://localhost:8080/", false )]
|
|
[DataRow( "https://localhost:8443/", false )]
|
|
[DataRow( "https://localhost:1337/", false )]
|
|
[DataRow( "https://8.8.8.8/", false )]
|
|
[DataRow( "https://192.168.1.1/", false )]
|
|
[DataRow( "https://127-0-0-1.mattstevens.co.uk/", false )]
|
|
[DataRow( "https://10-0-0-1.mattstevens.co.uk/", false )]
|
|
[DataRow( "https://192-168-1-1.mattstevens.co.uk/", false )]
|
|
[DataRow( "file://blah", false )]
|
|
[DataRow( "https://store.steampowered.com/", false )]
|
|
public void IsUriAllowed( string uri, bool shouldPass )
|
|
{
|
|
if ( shouldPass )
|
|
WebSurface.CheckUrlIsAllowed( new Uri( uri, UriKind.Absolute ) );
|
|
else
|
|
Assert.ThrowsException<InvalidOperationException>( () => WebSurface.CheckUrlIsAllowed( new Uri( uri, UriKind.Absolute ) ) );
|
|
}
|
|
}
|
|
}
|