Example #1
0
 public void TestBasicUrlComponents()
 {
     string basicUrl = "http://www.example.com/path";
     Assert.AreEqual(
         "www.example.com/path",
         PlaceholderResolver.GetUrlComponent(basicUrl, "RMVSCM")
     );
     Assert.AreEqual(
         "http",
         PlaceholderResolver.GetUrlComponent(basicUrl, "SCM")
     );
     Assert.AreEqual(
         string.Empty,
         PlaceholderResolver.GetUrlComponent(basicUrl, "USERINFO")
     );
     Assert.AreEqual(
         "www.example.com",
         PlaceholderResolver.GetUrlComponent(basicUrl, "HOST")
     );
     Assert.AreEqual(
         "80",
         PlaceholderResolver.GetUrlComponent(basicUrl, "PORT")
     );
     Assert.AreEqual(
         "/path",
         PlaceholderResolver.GetUrlComponent(basicUrl, "PATH")
     );
     Assert.AreEqual(
         string.Empty,
         PlaceholderResolver.GetUrlComponent(basicUrl, "QUERY")
     );
 }
Example #2
0
        public void TestBadUrlComponents()
        {
            // Bad URL
            Assert.AreEqual(
                string.Empty,
                PlaceholderResolver.GetUrlComponent("foo//bar", "SCM")
            );

            // Bad component
            Assert.IsNull(PlaceholderResolver.GetUrlComponent("http://example.com", "FOO"));
        }
Example #3
0
 public void KeePassTestVectors()
 {
     string url = "http://*****:*****@keepass.info:81/path/example.php?q=e&s=t";
     Assert.AreEqual(
         "user:[email protected]:81/path/example.php?q=e&s=t",
         PlaceholderResolver.GetUrlComponent(url, "RMVSCM")
     );
     Assert.AreEqual(
         "http",
         PlaceholderResolver.GetUrlComponent(url, "SCM")
     );
     Assert.AreEqual(
         "user:pw",
         PlaceholderResolver.GetUrlComponent(url, "USERINFO")
     );
     Assert.AreEqual(
         "user",
         PlaceholderResolver.GetUrlComponent(url, "USERNAME")
     );
     Assert.AreEqual(
         "pw",
         PlaceholderResolver.GetUrlComponent(url, "PASSWORD")
     );
     Assert.AreEqual(
         "keepass.info",
         PlaceholderResolver.GetUrlComponent(url, "HOST")
     );
     Assert.AreEqual(
         "81",
         PlaceholderResolver.GetUrlComponent(url, "PORT")
     );
     Assert.AreEqual(
         "/path/example.php",
         PlaceholderResolver.GetUrlComponent(url, "PATH")
     );
     Assert.AreEqual(
         "?q=e&s=t",
         PlaceholderResolver.GetUrlComponent(url, "QUERY")
     );
 }
Example #4
0
 public void TestMoreComplexUrlComponents()
 {
     string complexUrl = "https://[email protected]:1337/path/path?query=flaf";
     Assert.AreEqual(
         "[email protected]:1337/path/path?query=flaf",
         PlaceholderResolver.GetUrlComponent(complexUrl, "RMVSCM")
     );
     Assert.AreEqual(
         "https",
         PlaceholderResolver.GetUrlComponent(complexUrl, "SCM")
     );
     Assert.AreEqual(
         "sfuqua",
         PlaceholderResolver.GetUrlComponent(complexUrl, "USERINFO")
     );
     Assert.AreEqual(
         "sfuqua",
         PlaceholderResolver.GetUrlComponent(complexUrl, "USERNAME")
     );
     Assert.AreEqual(
         string.Empty,
         PlaceholderResolver.GetUrlComponent(complexUrl, "PASSWORD")
     );
     Assert.AreEqual(
         "host.bar.baz",
         PlaceholderResolver.GetUrlComponent(complexUrl, "HOST")
     );
     Assert.AreEqual(
         "1337",
         PlaceholderResolver.GetUrlComponent(complexUrl, "PORT")
     );
     Assert.AreEqual(
         "/path/path",
         PlaceholderResolver.GetUrlComponent(complexUrl, "PATH")
     );
     Assert.AreEqual(
         "?query=flaf",
         PlaceholderResolver.GetUrlComponent(complexUrl, "QUERY")
     );
 }
Example #5
0
 public void TestComplexUrlComponents()
 {
     string complexUrl = "foo://*****:*****@host.bar.baz/path/path?query=flaf";
     Assert.AreEqual(
         "sfuqua:[email protected]/path/path?query=flaf",
         PlaceholderResolver.GetUrlComponent(complexUrl, "RMVSCM")
     );
     Assert.AreEqual(
         "foo",
         PlaceholderResolver.GetUrlComponent(complexUrl, "SCM")
     );
     Assert.AreEqual(
         "sfuqua:blah",
         PlaceholderResolver.GetUrlComponent(complexUrl, "USERINFO")
     );
     Assert.AreEqual(
         "sfuqua",
         PlaceholderResolver.GetUrlComponent(complexUrl, "USERNAME")
     );
     Assert.AreEqual(
         "blah",
         PlaceholderResolver.GetUrlComponent(complexUrl, "PASSWORD")
     );
     Assert.AreEqual(
         "host.bar.baz",
         PlaceholderResolver.GetUrlComponent(complexUrl, "HOST")
     );
     Assert.AreEqual(
         "-1",
         PlaceholderResolver.GetUrlComponent(complexUrl, "PORT")
     );
     Assert.AreEqual(
         "/path/path",
         PlaceholderResolver.GetUrlComponent(complexUrl, "PATH")
     );
     Assert.AreEqual(
         "?query=flaf",
         PlaceholderResolver.GetUrlComponent(complexUrl, "QUERY")
     );
 }