public async Task Jwt_Request_ReturnType(Protocol protocol) { var defaultOptions = (await AblySandboxFixture.GetSettings()).CreateDefaultOptions(); var keyParts = defaultOptions.Key.Split(':'); var key = keyParts[0]; var secret = keyParts[1]; var authParams = new Dictionary <string, string> { ["environment"] = "sandbox", ["keyName"] = key, ["keySecret"] = secret, ["returnType"] = "jwt" }; var client = await GetRestClient(protocol, options => { options.AuthUrl = new Uri(EchoServer); options.AuthParams = authParams; options.Key = string.Empty; }); var stats = await client.StatsAsync(); stats.Should().NotBeNull(); }
public async Task WithCorrectCipherParams_DecryptsMessagesCorrectly(Protocol protocol) { var client = await GetRestClient(protocol); var settings = await AblySandboxFixture.GetSettings(); var channel = client.Channels.Get(TestEnvironmentSettings.PresenceChannelName, new ChannelOptions(settings.CipherParams)); var presence = await channel.Presence.GetAsync(); foreach (var message in presence.Items) { message.Encoding.Should().BeNullOrEmpty(); } }
private async Task <string> GetJwtStringAsync( bool invalid = false, int expiresIn = 3600, string clientId = "testClientIdDotNet", string capability = "{\"*\":[\"*\"]}", string jwtType = "", int encrypted = 0) { var settings = await AblySandboxFixture.GetSettings(); var defaultOptions = settings.CreateDefaultOptions(); var keyParts = defaultOptions.Key.Split(':'); if (keyParts.Length != 2) { throw new Exception($"Cannot create JWT Token. API Key '{defaultOptions.Key}' is not valid."); } var key = keyParts[0]; var secret = keyParts[1]; if (invalid) { secret = "invalid"; } var builder = new UriBuilder(EchoServer); var query = HttpUtility.ParseQueryString(string.Empty); query["keyName"] = key; query["keySecret"] = secret; query["expiresIn"] = expiresIn.ToString(); query["clientId"] = clientId; query["capability"] = capability; query["jwtType"] = jwtType; query["encrypted"] = encrypted.ToString(); query["environment"] = "sandbox"; builder.Query = query.ToQueryString(); var jwtStr = await _httpClient.GetStringAsync(builder.Uri); return(jwtStr); }