Пример #1
0
        public void TableUriBuilder_RegularUrl_SasTest()
        {
            // Arrange
            var uriString   = "https://account.core.table.windows.net/table?tn=table&sv=2015-04-05&spr=https&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sip=168.1.5.60-168.1.5.70&sr=b&sp=rw&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D";
            var originalUri = new UriBuilder(uriString);

            // Act
            var tableuribuilder = new TableUriBuilder(originalUri.Uri);
            Uri newUri          = tableuribuilder.ToUri();

            // Assert
            Assert.AreEqual("https", tableuribuilder.Scheme);
            Assert.AreEqual("account.core.table.windows.net", tableuribuilder.Host);
            Assert.AreEqual(443, tableuribuilder.Port);
            Assert.AreEqual(new DateTimeOffset(2015, 4, 30, 2, 23, 26, TimeSpan.Zero), tableuribuilder.Sas.ExpiresOn);
            Assert.AreEqual("", tableuribuilder.Sas.Identifier);
            Assert.AreEqual(TableSasIPRange.Parse("168.1.5.60-168.1.5.70"), tableuribuilder.Sas.IPRange);
            Assert.AreEqual("rw", tableuribuilder.Sas.Permissions);
            Assert.AreEqual(TableSasProtocol.Https, tableuribuilder.Sas.Protocol);
            Assert.AreEqual("b", tableuribuilder.Sas.Resource);
            Assert.IsNull(tableuribuilder.Sas.ResourceTypes);
            Assert.AreEqual("Z/RHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk=", tableuribuilder.Sas.Signature);
            Assert.AreEqual(new DateTimeOffset(2015, 4, 29, 22, 18, 26, TimeSpan.Zero), tableuribuilder.Sas.StartsOn);
            Assert.AreEqual("2015-04-05", tableuribuilder.Sas.Version);

            Assert.AreEqual("", tableuribuilder.Query);

            Assert.That(newUri.ToString(), Is.EqualTo(originalUri.Uri.ToString()));
        }
Пример #2
0
        public void TableBuilder_SasStartExpiryTimeFormats(string startTime, string expiryTime)
        {
            // Arrange
            Uri             initialUri      = new Uri($"https://account.table.core.windows.net/table?tn=tablename&sv=2020-04-08&st={WebUtility.UrlEncode(startTime)}&se={WebUtility.UrlEncode(expiryTime)}&sr=b&sp=racwd&sig=jQetX8odiJoZ7Yo0X8vWgh%2FMqRv9WE3GU%2Fr%2BLNMK3GU%3D");
            TableUriBuilder tableuribuilder = new TableUriBuilder(initialUri);

            // Act
            Uri resultUri = tableuribuilder.ToUri();

            // Assert
            Assert.That(resultUri.ToString(), Is.EqualTo(initialUri.ToString()));
            Assert.IsTrue(resultUri.PathAndQuery.Contains($"st={WebUtility.UrlEncode(startTime)}"));
            Assert.IsTrue(resultUri.PathAndQuery.Contains($"se={WebUtility.UrlEncode(expiryTime)}"));
        }
Пример #3
0
        public void TableBuilder_SasStartExpiryTimeFormats(string startTime, string expiryTime)
        {
            // Arrange
            Uri             initialUri      = new Uri($"https://account.table.core.windows.net/table?tn=tablename&sv=2020-04-08&st={WebUtility.UrlEncode(startTime)}&se={WebUtility.UrlEncode(expiryTime)}&sr=b&sp=racwd&sig=%2BLsuqDlN8Us5lp%2FGdyEUMnU1XA4HdXx%2BJUdtkRNr7qI%3D");
            TableUriBuilder tableuribuilder = new TableUriBuilder(initialUri);

            // Act
            Uri resultUri = tableuribuilder.ToUri();

            // Assert
            Assert.That(resultUri.ToString(), Is.EqualTo(initialUri.ToString()));
            Assert.IsTrue(resultUri.PathAndQuery.Contains($"st={WebUtility.UrlEncode(startTime)}"));
            Assert.IsTrue(resultUri.PathAndQuery.Contains($"se={WebUtility.UrlEncode(expiryTime)}"));
        }
Пример #4
0
        public void TableUriBuilder_RegularUrl_PortTest()
        {
            // Arrange
            var uriString   = "https://account.core.table.windows.net:8080/table";
            var originalUri = new UriBuilder(uriString);

            // Act
            var tableuribuilder = new TableUriBuilder(originalUri.Uri);
            Uri newUri          = tableuribuilder.ToUri();

            // Assert
            Assert.AreEqual("https", tableuribuilder.Scheme);
            Assert.AreEqual("account.core.table.windows.net", tableuribuilder.Host);
            Assert.AreEqual(8080, tableuribuilder.Port);
            Assert.IsNull(tableuribuilder.Sas);
            Assert.AreEqual("", tableuribuilder.Query);
            Assert.AreEqual(originalUri, newUri);
        }
Пример #5
0
        public void TableUriBuilder_IPStyleUrl_AccountOnlyTest()
        {
            // Arrange
            var uriString   = "https://127.0.0.1/account";
            var originalUri = new UriBuilder(uriString);

            // Act
            var tableuribuilder = new TableUriBuilder(originalUri.Uri);
            Uri newUri          = tableuribuilder.ToUri();

            // Assert
            Assert.AreEqual("https", tableuribuilder.Scheme);
            Assert.AreEqual("127.0.0.1", tableuribuilder.Host);
            Assert.AreEqual(443, tableuribuilder.Port);
            Assert.AreEqual("account", tableuribuilder.AccountName);
            Assert.IsNull(tableuribuilder.Sas);
            Assert.AreEqual("", tableuribuilder.Query);

            Assert.AreEqual(originalUri, newUri);
        }