public void ParseExtractsValues() { var signature = "SharedAccessSignature sr=amqps%3A%2F%2Fmy.eh.com%2Fsomepath%2F&sig=%2BLsuqDlN8Us5lp%2FGdyEUMnU1XA4HdXx%2BJUdtkRNr7qI%3D&se=1562258488&skn=keykeykey"; var parsed = SharedAccessSignature.ParseSignature(signature); Assert.That(parsed, Is.Not.Null, "There should have been a result returned."); Assert.That(parsed.Resource, Is.Not.Null.Or.Empty, "The resource should have been parsed."); Assert.That(parsed.KeyName, Is.Not.Null.Or.Empty, "The key should have been parsed."); Assert.That(parsed.ExpirationUtc, Is.Not.EqualTo(default(DateTime)), "The expiration should be parsed."); }
public void ParseProducesCorrectValues() { var host = "my.hubthing.com"; var path = "someHubInstance"; var keyName = "rootShared"; var key = "ABC123FFF333"; var validFor = TimeSpan.FromMinutes(30); var expiration = DateTime.UtcNow.Add(validFor); var signature = new SharedAccessSignature(TransportType.AmqpTcp, host, path, keyName, key, validFor); var parsed = SharedAccessSignature.ParseSignature(signature.ToString()); Assert.That(parsed, Is.Not.Null, "There should have been a result returned."); Assert.That(parsed.Resource, Contains.Substring(host.ToLower()), "The resource should contain the host."); Assert.That(parsed.Resource, Contains.Substring(path.ToLower()), "The resource should contain the Event Hub path."); Assert.That(parsed.KeyName, Is.EqualTo(keyName), "The key name should have been parsed."); Assert.That(parsed.ExpirationUtc, Is.EqualTo(expiration).Within(TimeSpan.FromSeconds(5)), "The expiration should be parsed."); }
public void ParseToleratesExtraTokens(string signature) { Assert.That(() => SharedAccessSignature.ParseSignature(signature), Throws.Nothing); }
public void ParseToleratesTrailingDelimiters(string signature) { Assert.That(() => SharedAccessSignature.ParseSignature(signature), Throws.Nothing); }
public void ParseSignatureFailsWhenExpirationIsInvalid(string signature) { Assert.That(() => SharedAccessSignature.ParseSignature(signature), Throws.ArgumentException); }
public void ParseSignatureFailsWhenValuesAreMissing(string signature) { Assert.That(() => SharedAccessSignature.ParseSignature(signature), Throws.ArgumentException); }