public async Task CanGenerateToken() { var tokenProvider = new SecureTokenProvider(_serviceStackSerializer); var gateway = new SecureGISGateway(_serviceStackSerializer); var endpoint = new ArcGISServerEndpoint("Oil/MapServer"); var response = await gateway.Ping(endpoint); var token = await tokenProvider.CheckGenerateToken(CancellationToken.None); Assert.NotNull(token); Assert.NotNull(token.Value); Assert.False(token.IsExpired); Assert.Null(response.Error); gateway = new SecureGISGateway(new JsonDotNetSerializer()); response = await gateway.Ping(endpoint); token = await tokenProvider.CheckGenerateToken(CancellationToken.None); Assert.NotNull(token); Assert.NotNull(token.Value); Assert.False(token.IsExpired); Assert.Null(response.Error); }
public async Task InvalidTokenReported() { var tokenProvider = new SecureTokenProvider(_serviceStackSerializer); var gateway = new SecureGISGateway2(_serviceStackSerializer, tokenProvider); var endpoint = new ArcGISServerEndpoint("Oil/MapServer"); var response = await gateway.Ping(endpoint); var token = await tokenProvider.CheckGenerateToken(CancellationToken.None); Assert.NotNull(token); Assert.NotNull(token.Value); Assert.False(token.IsExpired); Assert.Null(token.Error); Assert.Null(response.Error); token.Value += "chuff"; var query = new Query(@"/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint()) { Token = token.Value }; var exception = await ThrowsAsync <InvalidOperationException>(async() => await gateway.Query <Point>(query)); Assert.NotNull(exception); Assert.Contains("Invalid token", exception.Message); }