public async Task ShouldStoreMultipleCredentials() { // given await TokenProvider.GetAccessTokenForRequestAsync(); var otherProvider = new CamundaCloudTokenProviderBuilder() .UseAuthServer(_requestUri) .UseClientId(_clientId = "OTHERID") .UseClientSecret(_clientSecret = "OTHERSECRET") .UseAudience(_audience = "OTHER_AUDIENCE") .Build(); otherProvider.SetHttpMessageHandler(MessageHandlerStub); otherProvider.TokenStoragePath = TokenStoragePath; Token = "OTHER_TOKEN"; // when var token = await otherProvider.GetAccessTokenForRequestAsync(); // then Assert.AreEqual("OTHER_TOKEN", token); var files = Directory.GetFiles(TokenStoragePath); Assert.AreEqual(1, files.Length); var tokenFile = files[0]; var content = File.ReadAllText(tokenFile); var credentials = JsonConvert.DeserializeObject <Dictionary <string, CamundaCloudTokenProvider.AccessToken> >(content); Assert.AreEqual(credentials.Count, 2); Assert.AreEqual(token, credentials["OTHER_AUDIENCE"].Token); Assert.AreEqual("REQUESTED_TOKEN", credentials["AUDIENCE"].Token); }
public void Init() { TokenProvider = new CamundaCloudTokenProviderBuilder() .UseAuthServer("https://local.de") .UseClientId("ID") .UseClientSecret("SECRET") .UseAudience("AUDIENCE") .Build(); MessageHandlerStub = new HttpMessageHandlerStub(); TokenProvider.SetHttpMessageHandler(MessageHandlerStub); TokenStoragePath = Path.GetTempPath() + ".zeebe/"; TokenProvider.TokenStoragePath = TokenStoragePath; ExpiresIn = 3600; Token = "REQUESTED_TOKEN"; }
public void Init() { _requestUri = "https://local.de"; _clientId = "ID"; _clientSecret = "SECRET"; _audience = "AUDIENCE"; TokenProvider = new CamundaCloudTokenProviderBuilder() .UseAuthServer(_requestUri) .UseClientId(_clientId) .UseClientSecret(_clientSecret) .UseAudience(_audience) .Build(); MessageHandlerStub = new HttpMessageHandlerStub(); TokenProvider.SetHttpMessageHandler(MessageHandlerStub); TokenStoragePath = Path.GetTempPath() + ".zeebe/"; TokenProvider.TokenStoragePath = TokenStoragePath; ExpiresIn = 3600; Token = "REQUESTED_TOKEN"; }
public async Task ShouldNotUseCachedFileForOtherAudience() { // given Token = "STORED_TOKEN"; await TokenProvider.GetAccessTokenForRequestAsync(); var otherProvider = new CamundaCloudTokenProviderBuilder() .UseAuthServer(_requestUri) .UseClientId(_clientId = "OTHERID") .UseClientSecret(_clientSecret = "OTHERSECRET") .UseAudience(_audience = "OTHER_AUDIENCE") .Build(); otherProvider.SetHttpMessageHandler(MessageHandlerStub); otherProvider.TokenStoragePath = TokenStoragePath; Token = "OTHER_TOKEN"; // when var token = await otherProvider.GetAccessTokenForRequestAsync(); // then Assert.AreEqual("OTHER_TOKEN", token); }