Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update Site.cs (#693) Fix #311 * Add a test and refactor the url validator method. Co-authored-by: Thiago Yuri <thiago.souza@ccc.ufcg.edu.br>
- Loading branch information
1 parent
784b70e
commit a101907
Showing
3 changed files
with
35 additions
and
2 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
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,32 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SenseNet.Portal; | ||
using SenseNet.Tests; | ||
|
||
namespace SenseNet.Services.Tests | ||
{ | ||
[TestClass] | ||
public class SiteTests : TestBase | ||
{ | ||
[TestMethod] | ||
public void Site_UppercaseUrl() | ||
{ | ||
Assert.IsTrue(Site.IsValidSiteUrl("example.com")); | ||
Assert.IsTrue(Site.IsValidSiteUrl("example.com:1234")); // a port is allowed | ||
Assert.IsTrue(Site.IsValidSiteUrl("exAmPlE.cOm")); // uppercase url | ||
Assert.IsTrue(Site.IsValidSiteUrl("www.example.com")); | ||
Assert.IsTrue(Site.IsValidSiteUrl("sub1.sub2.example.com")); | ||
|
||
Assert.IsFalse(Site.IsValidSiteUrl("")); | ||
Assert.IsFalse(Site.IsValidSiteUrl(".")); | ||
Assert.IsFalse(Site.IsValidSiteUrl(".com")); | ||
Assert.IsFalse(Site.IsValidSiteUrl("http://example.com")); // a schema prefix is not allowed | ||
Assert.IsFalse(Site.IsValidSiteUrl("http:/example.com")); | ||
Assert.IsFalse(Site.IsValidSiteUrl("/example.com")); | ||
Assert.IsFalse(Site.IsValidSiteUrl("//example.com")); | ||
Assert.IsFalse(Site.IsValidSiteUrl(":/example.com")); | ||
Assert.IsFalse(Site.IsValidSiteUrl("example.com//")); | ||
Assert.IsFalse(Site.IsValidSiteUrl("example.com/file.txt")); // only a domain is allowed | ||
Assert.IsFalse(Site.IsValidSiteUrl("example.com/page1/page2")); // only a domain is allowed | ||
} | ||
} | ||
} |