Beispiel #1
0
        public void ArcGISServerEndpointHasCorrectFormat()
        {
            Assert.Throws <ArgumentNullException>(() => new ArcGISServerEndpoint(""));

            var endpoint2 = new ArcGISServerEndpoint("/rest/services/rest/services/rest/services/");

            Assert.True(endpoint2.RelativeUrl.StartsWith("rest/services/", StringComparison.InvariantCultureIgnoreCase));

            var endpoint3 = new ArcGISServerEndpoint("something/MapServer");

            Assert.True(endpoint3.RelativeUrl.StartsWith("rest/services/", StringComparison.InvariantCultureIgnoreCase));

            var endpoint4 = new ArcGISServerEndpoint("/rest/services/");

            Assert.True(endpoint4.RelativeUrl.StartsWith("rest/services/", StringComparison.InvariantCultureIgnoreCase));

            var endpoint5 = new ArcGISServerEndpoint("rest/services/");

            Assert.True(endpoint5.RelativeUrl.StartsWith("rest/services/", StringComparison.InvariantCultureIgnoreCase));

            var endpoint6 = new ArcGISServerEndpoint("rest/services");

            Assert.True(endpoint6.RelativeUrl.StartsWith("rest/services/", StringComparison.InvariantCultureIgnoreCase));

            var endpoint7 = new ArcGISServerEndpoint("/rest/services");

            Assert.True(endpoint7.RelativeUrl.StartsWith("rest/services/", StringComparison.InvariantCultureIgnoreCase));

            var endpoint8 = new ArcGISServerEndpoint("/");

            Assert.True(endpoint8.RelativeUrl.StartsWith("rest/services/", StringComparison.InvariantCultureIgnoreCase));
        }
Beispiel #2
0
        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(string rootUrl, string username, string password, string relativeUrl)
        {
            var tokenProvider = new TokenProvider(rootUrl, username, password);
            var gateway       = new PortalGateway(rootUrl, tokenProvider: tokenProvider);
            var endpoint      = new ArcGISServerEndpoint(relativeUrl);

            var token = await IntegrationTestFixture.TestPolicy.Execute(() =>
            {
                return(tokenProvider.CheckGenerateToken(CancellationToken.None));
            });

            Assert.NotNull(token);
            Assert.NotNull(token.Value);
            Assert.False(token.IsExpired);
            Assert.Null(token.Error);

            token.Value += "chuff";
            var query = new Query(endpoint)
            {
                Token = token.Value
            };

            var exception = await Assert.ThrowsAsync <InvalidOperationException>(() => gateway.Query <Point>(query));

            Assert.NotNull(exception);
            Assert.Contains("invalid token", exception.Message.ToLowerInvariant());
        }
Beispiel #4
0
 /// <summary>
 /// Represents a request for a find against a service resource
 /// </summary>
 /// <param name="endpoint">Resource to apply the query against</param>
 public Find(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null)
     : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Find, beforeRequest, afterRequest)
 {
     FuzzySearch    = true;
     ReturnGeometry = true;
     ReturnZ        = true;
 }
 public QueryAttachments(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action <string> afterRequest = null)
     : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.QueryAttachments, beforeRequest, afterRequest)
 {
     ObjectIds = new List <long>();
     GlobalIds = new List <string>();
     SizeRange = new List <int>();
 }
        public ReverseGeocode(ArcGISServerEndpoint endpoint)
        {
            Guard.AgainstNullArgument("endpoint", endpoint);
            Endpoint = new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.ReverseGeocode);

            Distance = 100;
        }
Beispiel #7
0
        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);
        }
 AttachmentToPost(ArcGISServerEndpoint endpoint, long objectID, string fileName, string contentType, bool isUpdate = false, Action beforeRequest = null, Action <string> afterRequest = null)
     : base(endpoint.RelativeUrl.Trim('/') + string.Format("/{0}/{1}", objectID, isUpdate ? "updateAttachment" : "addAttachment"), beforeRequest, afterRequest)
 {
     ObjectID    = objectID;
     FileName    = fileName;
     ContentType = contentType;
 }
Beispiel #9
0
 /// <summary>
 /// Requests an export of the map resources. Returns the image link in the response
 /// </summary>
 /// <param name="endpoint">Resource to apply the export against</param>
 public ExportMap(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action<string> afterRequest = null)
     : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.ExportMap, beforeRequest, afterRequest)
 {
     Size = new List<int> { 400, 400 };
     Dpi = 96;
     ImageFormat = "png";
 }
Beispiel #10
0
 public SingleInputCustomGeocode(ArcGISServerEndpoint endpoint)
 {
     if (endpoint == null)
     {
         throw new ArgumentNullException("endpoint");
     }
     Endpoint = new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.SingleInputCustomGeocode);
 }
Beispiel #11
0
 public ApplyEdits(ArcGISServerEndpoint endpoint)
 {
     if (endpoint == null)
     {
         throw new ArgumentNullException("endpoint");
     }
     Endpoint = new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.ApplyEdits);
 }
Beispiel #12
0
 /// <summary>
 /// Represents a request for a query against a service resource
 /// </summary>
 /// <param name="endpoint">Resource to apply the query against</param>
 public Query(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null)
     : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Query, beforeRequest, afterRequest)
 {
     Where               = "1=1";
     OutFields           = new List <string>();
     ReturnGeometry      = true;
     SpatialRelationship = SpatialRelationshipTypes.Intersects;
 }
        public SingleInputGeocode(ArcGISServerEndpoint endpoint)
        {
            Guard.AgainstNullArgument("endpoint", endpoint);
            Endpoint = new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.SingleInputGeocode);

            MaxResults = 1;
            Distance   = null;
        }
 public ApplyEdits(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action afterRequest = null)
     : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.ApplyEdits, beforeRequest, afterRequest)
 {
     Adds              = new List <Feature <T> >();
     Updates           = new List <Feature <T> >();
     Deletes           = new List <long>();
     RollbackOnFailure = true;
 }
Beispiel #15
0
        public void ArcGISServerEndpointHasCorrectFormatWithRelativeUrl(string relativeUrl)
        {
            var endpoint = new ArcGISServerEndpoint(relativeUrl);

            Assert.Equal("rest/services/" + relativeUrl, endpoint.RelativeUrl);

            endpoint = relativeUrl.AsEndpoint();
            Assert.Equal("rest/services/" + relativeUrl, endpoint.RelativeUrl);
        }
Beispiel #16
0
        /// <summary>
        /// Represents a request for a find against a service resource
        /// </summary>
        /// <param name="endpoint">Resource to apply the query against</param>
        public Find(ArcGISServerEndpoint endpoint)
        {
            Guard.AgainstNullArgument("endpoint", endpoint);
            Endpoint = new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Find);

            FuzzySearch    = true;
            ReturnGeometry = true;
            ReturnZ        = true;
        }
Beispiel #17
0
        public async Task CanPingServer()
        {
            var gateway = new ArcGISGateway(_serviceStackSerializer);

            var endpoint = new ArcGISServerEndpoint("/");

            var response = await gateway.Ping(endpoint);

            Assert.Null(response.Error);
        }
        public async Task CannotAccessSecureResourceWithoutToken(string rootUrl, string relativeUrl)
        {
            var gateway  = new PortalGateway(rootUrl);
            var endpoint = new ArcGISServerEndpoint(relativeUrl);

            var exception = await Assert.ThrowsAsync <InvalidOperationException>(() => gateway.Ping(endpoint));

            Assert.NotNull(exception);
            Assert.Contains("token required.", exception.Message.ToLowerInvariant());
        }
Beispiel #19
0
        public ReverseGeocode(ArcGISServerEndpoint endpoint)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }
            Endpoint = new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.ReverseGeocode);

            Distance = 100;
        }
Beispiel #20
0
        /// <summary>
        /// Represents a request for a query against a service resource
        /// </summary>
        /// <param name="endpoint">Resource to apply the query against</param>
        public Query(ArcGISServerEndpoint endpoint)
        {
            Guard.AgainstNullArgument("endpoint", endpoint);
            Endpoint = new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Query);

            Where               = "1=1";
            OutFields           = new List <string>();
            ReturnGeometry      = true;
            SpatialRelationship = SpatialRelationshipTypes.Intersects;
        }
        public AttachmentToPost(ArcGISServerEndpoint endpoint, long objectID, string attachmentBase64Encoded, string fileName, string contentType, bool isUpdate = false)
            : this(endpoint, objectID, fileName, contentType, isUpdate)
        {
            if (string.IsNullOrWhiteSpace(attachmentBase64Encoded))
            {
                throw new ArgumentNullException(nameof(attachmentBase64Encoded));
            }

            AttachmentBase64Encoded = attachmentBase64Encoded;
            Attachment = Convert.FromBase64String(AttachmentBase64Encoded);
        }
Beispiel #22
0
        public async Task CannotAccessSecureResourceWithoutToken()
        {
            var gateway = new NonSecureGISGateway(_serviceStackSerializer);

            var endpoint = new ArcGISServerEndpoint("Oil/MapServer");

            var exception = await ThrowsAsync <InvalidOperationException>(async() => await gateway.Ping(endpoint));

            Assert.NotNull(exception);
            Assert.Contains("Unauthorized access", exception.Message);
        }
Beispiel #23
0
        /// <summary>
        /// Represents a request for a find against a service resource
        /// </summary>
        /// <param name="endpoint">Resource to apply the query against</param>
        public Find(ArcGISServerEndpoint endpoint)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }
            Endpoint = new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Find);

            FuzzySearch    = true;
            ReturnGeometry = true;
            ReturnZ        = true;
        }
Beispiel #24
0
        public async Task CanPingServer(string rootUrl)
        {
            var gateway  = new PortalGateway(rootUrl);
            var endpoint = new ArcGISServerEndpoint("/");

            var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() =>
            {
                return(gateway.Ping(endpoint));
            });

            Assert.Null(response.Error);
        }
Beispiel #25
0
        /// <summary>
        /// Represents a request for a query against a service resource
        /// </summary>
        /// <param name="endpoint">Resource to apply the query against</param>
        public Query(ArcGISServerEndpoint endpoint)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }
            Endpoint = new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.Query);

            Where               = "1=1";
            OutFields           = new List <String>();
            ReturnGeometry      = true;
            SpatialRelationship = SpatialRelationshipTypes.Intersects;
        }
Beispiel #26
0
        public async Task CanGetAnythingFromServer()
        {
            var gateway = new ArcGISGateway(_serviceStackSerializer);

            var endpoint = new ArcGISServerEndpoint("/Earthquakes/EarthquakesFromLastSevenDays/MapServer");

            var response = await gateway.GetAnything(endpoint);

            Assert.Null(response.Error);
            Assert.True(response.ContainsKey("capabilities"));
            Assert.True(response.ContainsKey("mapName"));
            Assert.True(response.ContainsKey("layers"));
            Assert.True(response.ContainsKey("documentInfo"));
        }
Beispiel #27
0
 public CreateReplica(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action <string> afterRequest = null)
     : base(endpoint.RelativeUrl.Trim('/') + "/" + Operations.CreateReplica, beforeRequest, afterRequest)
 {
     ReturnAttachments          = false;
     TargetType                 = "client";
     TransportType              = "esriTransportTypeEmbedded";
     Layers                     = new List <int>();
     LayerQueries               = new List <LayerQuery>();
     ReturnAttachmentsDataByUrl = false;
     SyncModel                  = "none";
     AttachmentsSyncDirection   = "none";
     DataFormat                 = "json";
     IsAsync                    = false;
 }
        public async Task CanGetAnythingFromServer(string rootUrl, string relativeUrl)
        {
            var gateway  = new ArcGISGateway(rootUrl, null, new ServiceStackSerializer());
            var endpoint = new ArcGISServerEndpoint(relativeUrl);
            var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() =>
            {
                return(gateway.GetAnything(endpoint));
            });

            Assert.Null(response.Error);
            Assert.True(response.ContainsKey("capabilities"));
            Assert.True(response.ContainsKey("mapName"));
            Assert.True(response.ContainsKey("layers"));
            Assert.True(response.ContainsKey("documentInfo"));
        }
 public Task <AgsObject> GetAnything(ArcGISServerEndpoint endpoint)
 {
     return(Get <AgsObject>(endpoint, CancellationToken.None));
 }
Beispiel #30
0
 public SingleInputGeocode(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Action <string> afterRequest = null)
     : base(new ArcGISServerEndpoint(endpoint.RelativeUrl.Trim('/') + "/" + Operations.SingleInputGeocode), beforeRequest, afterRequest)
 {
     MaxResults = 1;
     Distance   = null;
 }