Skip to content

Commit

Permalink
Adding a rest keyword to get the rest endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mjindalmotiv8 committed Apr 21, 2022
1 parent 438e173 commit c8abaff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Momento/MomentoSigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public MomentoSigner(string jwkJsonString)
/// <summary>
/// Create a pre-signed HTTPS URL.
/// </summary>
/// <param name="hostname">Hostname of the SimpleCacheService. Use the value returned from CreateSigningKey's response.</param>
/// <param name="hostname">Hostname of the SimpleCacheService. Use the value returned from CreateSigningKey's response. A rest keyword is prepended to the hostname</param>
/// <param name="signingRequest">The parameters used for generating a pre-signed URL</param>
/// <returns></returns>
public string CreatePresignedUrl(string hostname, SigningRequest signingRequest)
Expand All @@ -38,8 +38,8 @@ public string CreatePresignedUrl(string hostname, SigningRequest signingRequest)

return signingRequest.CacheOperation switch
{
CacheOperation.GET => $"https://{hostname}/cache/get/{cacheName}/{cacheKey}?token={jwtToken}",
CacheOperation.SET => $"https://{hostname}/cache/set/{cacheName}/{cacheKey}?ttl_milliseconds={signingRequest.TtlSeconds * (ulong)1000}&token={jwtToken}",
CacheOperation.GET => $"https://rest.{hostname}/cache/get/{cacheName}/{cacheKey}?token={jwtToken}",
CacheOperation.SET => $"https://rest.{hostname}/cache/set/{cacheName}/{cacheKey}?ttl_milliseconds={signingRequest.TtlSeconds * (ulong)1000}&token={jwtToken}",
_ => throw new NotImplementedException($"Unhandled {signingRequest.CacheOperation}")
};
}
Expand Down
6 changes: 3 additions & 3 deletions MomentoTest/MomentoSignerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void TestPresignedUrlForGet()
bool result = Uri.TryCreate(url, UriKind.Absolute, out uriResult);
Assert.True(result);
Assert.Equal(Uri.UriSchemeHttps, uriResult.Scheme);
Assert.StartsWith("https://foobar.com/cache/get/testCacheName/testCacheKey?token=", url);
Assert.StartsWith("https://rest.foobar.com/cache/get/testCacheName/testCacheKey?token=", url);
}

[Fact]
Expand All @@ -68,7 +68,7 @@ public void TestPresignedUrlForSet()
bool result = Uri.TryCreate(url, UriKind.Absolute, out uriResult);
Assert.True(result);
Assert.Equal(Uri.UriSchemeHttps, uriResult.Scheme);
Assert.StartsWith("https://foobar.com/cache/set/testCacheName/testCacheKey?ttl_milliseconds=4294967295000&token=", url);
Assert.StartsWith("https://rest.foobar.com/cache/set/testCacheName/testCacheKey?ttl_milliseconds=4294967295000&token=", url);
}

[Fact]
Expand All @@ -83,7 +83,7 @@ public void TestUrlEncoding()
bool result = Uri.TryCreate(url, UriKind.Absolute, out uriResult);
Assert.True(result);
Assert.Equal(Uri.UriSchemeHttps, uriResult.Scheme);
Assert.StartsWith("https://foobar.com/cache/get/testCacheName/%23%24%26%5c%27%2b%2c%2f%3a%3b%3d%3f%40%5b%5d?token=", url);
Assert.StartsWith("https://rest.foobar.com/cache/get/testCacheName/%23%24%26%5c%27%2b%2c%2f%3a%3b%3d%3f%40%5b%5d?token=", url);
}

[Fact]
Expand Down

0 comments on commit c8abaff

Please sign in to comment.