MFS - Map File Service - Test Cases

1. Test the MFS GetMapFile request.

MAP-172
1a. Create a token using get_map_file as the resource and tests as the project_name:

{
  "appkey": "insert-your-appkey-here",
  "resource": "get_map_file",
  "project_name": "tests"
}

1b. Using the header X-API-KEY with the value from step 1a, send a message using the following URL:
```url
https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.0.0&request=GetMapFile&project=tests&map=osm-tests-wms&format=text/plain

**1c.** After sending a message, the response should look like:
```text  
MAP
    NAME "OSM_Basemap"
    STATUS ON
    SIZE 256 256
    SYMBOLSET "/img/shared/symbols/test.sym"

...

                WIDTH 2
            END # STYLE
        END # CLASS
    END # LAYER
END # MAP

2. Test the MFS GetMapFile request returning a JSON mapfile.

MAP-172
2a. Create a token using get_map_file as the resource and tests as the project_name:

{
  "appkey": "insert-your-appkey-here",
  "resource": "get_map_file"
  "project_name": "tests"
}

2b. Using the header X-API-KEY with the value from step 2a, send a message using the following URL:

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.0.0&request=GetMapFile&project=tests&map=osm-tests-wms&format=application/json

2c. After sending a message, the response should look like this:

{
    "__type__": "map",
    "name": "OSM_Basemap",
    "status": "ON",
    "size": [

...

                }
            ]
        }
    ]
}

3.1 Test the MFS ListMapFiles by appkey request.

MAP-167
3a. Create a token using list_map_files as the resource:

{
  "appkey": "insert-your-appkey-here",
  "resource": "list_map_files"
}

3b. Using the header X-API-KEY with the value from step 3a, send a message using the following URL:

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.1.0&request=ListMapFiles

3c. After sending a message, the response should look like this:

{
    "response": "success",
    "message": [
        {
            "project": "tests",
            "id": 2,
            "map_name": "osm-tests-wfs",
            "map_description": "OSM map test",
            "service_id": 7,
            "enabled_flag": true,
            "create_user": "DB0400",
            "create_timestamp": "2021-04-13T09:41:00",
            "last_update_user": "unit-test",
            "last_update_timestamp": "2021-08-20T10:11:27",
            "map_project_id": 1,
            "map_editable": false,
            "app_enabled": true,
            "support_files": [
                {
                    "ms_errorfile": "osm-tests-wfs.log",
                    "fontset": {},
                    "symbolset": {},
                    "headers": null,
                    "templates": null,
                    "footers": null
                }
            ]
        },
           ...
        {
            "project": "attca",
            "id": 371,
            "map_name": "attca-plant",
            "map_description": "ATT plant map for WMTS",
            "service_id": 7,
            "enabled_flag": true,
            "create_user": "DB0400",
            "create_timestamp": "2022-09-26T16:39:40",
            "last_update_user": "DB0400",
            "last_update_timestamp": "2022-09-26T16:39:40",
            "map_project_id": 8,
            "map_editable": true,
            "app_enabled": true,
            "support_files": [
                {
                    "ms_errorfile": null,
                    "fontset": null,
                    "symbolset": null,
                    "headers": null,
                    "templates": null,
                    "footers": null
                }
            ]
        },
        {
            "project": "demo",
            "id": 372,
            "map_name": "dannys-changed-map",
            "map_description": "This is a test map updated",
            "service_id": 7,
            "enabled_flag": true,
            "create_user": "DB0095",
            "create_timestamp": "2022-10-05T12:56:16",
            "last_update_user": "DB0095",
            "last_update_timestamp": "2022-10-05T13:01:30",
            "map_project_id": 12,
            "map_editable": null,
            "app_enabled": true,
            "support_files": [
                {
                    "ms_errorfile": null,
                    "fontset": null,
                    "symbolset": null,
                    "headers": null,
                    "templates": null,
                    "footers": null
                }
            ]
        },
        {
            "project": "tests",
            "id": 373,
            "map_name": "my-new-map-testing1",
            "map_description": "This is a new test map for QA",
            "service_id": 7,
            "enabled_flag": true,
            "create_user": "DB0400",
            "create_timestamp": "2022-10-10T13:50:58",
            "last_update_user": "DB0400",
            "last_update_timestamp": "2022-10-10T13:50:58",
            "map_project_id": 1,
            "map_editable": null,
            "app_enabled": true,
            "support_files": [
                {
                    "ms_errorfile": null,
                    "fontset": null,
                    "symbolset": null,
                    "headers": null,
                    "templates": null,
                    "footers": null
                }
            ]
        },
        {
            "project": "pge",
            "id": 376,
            "map_name": "pge-plant-wms",
            "map_description": "PGE Plant map",
            "service_id": 7,
            "enabled_flag": true,
            "create_user": "DB0400",
            "create_timestamp": "2022-10-15T00:01:37",
            "last_update_user": "DB0400",
            "last_update_timestamp": "2022-10-15T00:01:37",
            "map_project_id": 15,
            "map_editable": null,
            "app_enabled": true,
            "support_files": [
                {
                    "ms_errorfile": null,
                    "fontset": null,
                    "symbolset": null,
                    "headers": null,
                    "templates": null,
                    "footers": null
                }
            ]
        }
    ]
}

3.2 Test the MFS ListMapFiles by project request.

MAP-167
3a. Create a token using list_map_files as the resource:

{
  "appkey": "insert-your-appkey-here",
  "resource": "list_map_files"
}

3b. Using the header X-API-KEY with the value from step 3a, send a message using the following URL:
Note: make sure to add project query parameter in the request

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.1.0&request=ListMapFiles&project=tests

3c. After sending a message, the response should look like this:

{
    "response": "success",
    "message": [
        {
            "project": "tests",
            "mapfile": "test-stringify.map",
            "supporting files": {
                "ms_errorfile": null,
                "fontset": {},
                "symbolset": {},
                "headers": null,
                "templates": null,
                "footers": null
            }
        },
        {
            "project": "tests",
            "mapfile": "map-test-edit-name.map",
            "supporting files": {
                "ms_errorfile": "osm-tests-wms.log",
                "fontset": "/img/shared/shared.font",
                "symbolset": "/img/shared/shared.sym",
                "headers": null,
                "templates": [
                    "osm-tests-wms.html"
                ],
                "footers": null
            }
        },
        {
            "project": "tests",
            "mapfile": "osm-tests-wfs.map",
            "supporting files": {
                "ms_errorfile": "osm-tests-wfs.log",
                "fontset": {},
                "symbolset": {},
                "headers": null,
                "templates": null,
                "footers": null
            }
        },

        ...

        {
            "project": "tests",
            "mapfile": "osm-tests-wms.map",
            "supporting files": {
                "ms_errorfile": "osm-tests-wms.log",
                "fontset": "/img/shared/shared.font",
                "symbolset": "/img/shared/shared.sym",
                "headers": null,
                "templates": [
                    "osm-tests-wms.html"
                ],
                "footers": null
            }
        }
    ]
}

3.3 Test the MFS ListMapFiles request by mapfile.

MAP-167
3a. Create a token using list_map_files as the resource:

{
  "appkey": "insert-your-appkey-here",
  "resource": "list_map_files"
}

3b. Using the header X-API-KEY with the value from step 3a, send a message using the following URL:
Note: make sure to add project and mapfile query parameters in the request

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.1.0&request=ListMapFiles&map=osm-tests-wms&project=tests

3c. After sending a message, the response should look like this:

{
    "response": "success",
    "message": {
        "mapfile": "osm-tests-wms.map",
        "supporting files": {
            "ms_errorfile": "osm-tests-wms.log",
            "fontset": "/img/shared/shared.font",
            "symbolset": "/img/shared/shared.sym",
            "headers": null,
            "templates": [
                "osm-tests-wms.html"
            ],
            "footers": null
        }
    }
}

4. Test the MFS PutMapFile request to create a new mapfile.

MAP-176
4a. Create a token using put_map_file as the resource and tests as the project_name:

{
  "appkey": "insert-your-appkey-here",
  "resource": "create_map_file"
  "project_name": "tests"
}

4b. Using the header X-API-KEY with the value from step 4a, send a message using the following URL:

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.0.0&request=PutMapFile&project=tests&map=map-test1&username=DB0400&newmapdescription=This is a new test map for QA

4c. After sending a message, the response should look like this:

{
  "response": "success", 
  "message": "New map file map-test1 created in tests project"
}

If map-test1 already exists in EFS drive, the response should look like this:

{
  "response": "success", 
  "message": "Map file map-test1 was edited"
}

4d. To verify that map-test1 exists, run through steps 3a - 3c to view all map files


5. Test the MFS PutMapFile request to edit an existing mapfile name.

MAP-176
5a. Create a token using put_map_file as the resource and tests as the project_name:

{
  "appkey": "insert-your-appkey-here",
  "resource": "edit_map_file"
  "project_name": "tests"
}

5b. Using the header X-API-KEY with the value from step 5a, send a message using the following URL:

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.0.0&request=PutMapFile&project=tests&map=map-test-edit-name&username=DB0400&newmapname=map-test-edit-name2  

5c. After sending a message, the response should look like this:

{
  "response": "success", 
  "message": "Map file map-test-edit-name was edited"
}

If map-test-edit-name does not exist, the response should look like this:

{
  "response": "success", 
  "message": "New map file map-test-edit-name created in tests project"
}

Revert the map file name back to the original name

5d. Create a new token using edit_map_file as the resource and tests as the project_name:

{
  "appkey": "insert-your-appkey-here",
  "resource": "edit_map_file",
  "project_name": "tests"
}

5e. Using the header X-API-KEY with the value from step 5d, send a message using the following URL:

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.0.0&request=PutMapFile&project=tests&map=map-test-edit-name&newmapname=map-test-edit-name  

5f. After sending a message, the response should look like this:

{
  "response": "success", 
  "message": "Map file map-test-edit-name2 was edited"
}

6. Test the MFS PutMapFile request to edit an existing mapfile project name.

MAP-176
6a. Create a token using edit_map_file as the resource tests as the project_name:

{
  "appkey": "insert-your-appkey-here",
  "resource": "edit_map_file"
  "project_name": "tests"
}

6b. Using the header X-API-KEY with the value from step 6a, send a message using the following URL:

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.0.0&request=PutMapFile&project=tests&map=edited-map&newprojectname=tests2

6c. After sending a message, the response should look like this:

{
  "response": "success", 
  "message": "Map file edited-map was edited"
}

If edited-map does not exist, the response should look like this:

{
  "response": "success", 
  "message": "New map file edited-map created in tests project"
}

Revert the map file project back to the original tests project

7d. Create a new token using edit_map_file as the resource and tests2 as the project_name:

{
  "appkey": "insert-your-appkey-here",
  "resource": "edit_map_file",
  "project_name": "tests2"
}

7e. Using the header X-API-KEY with the value from step 8d, send a message using the following URL:

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.0.0&request=PutMapFile&project=tests2&map=edited-map&newprojectname=tests

7f. After sending a message, the response should look like this:

{
  "response": "success", 
  "message": "Map file edited-map was edited"
}

8. Test the MFS PutMapFile request to edit the contents of an existing mapfile.

MAP-176
8a. Create a token using edit_map_file as the resource and tests as the project_name:

{
  "appkey": "insert-your-appkey-here",
  "resource": "edit_map_file",
  "project_name": "tests"
}

8b. Use the following text as the body of the request:
text MAP NAME new LAYER NAME test layer END END END
8c. Using the header X-API-KEY with the value from step 8a, and the body from step 8b, send a message using the following URL:
```url
https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.0.0&request=PutMapFile&project=tests&map=edited-map-contents

**8d.** After sending a message, the response should look like this:  
 ```json  
 {
   "response": "success", 
   "message": "Map file contents were edited"
 }
 ```

---
## 9. Test the MFS ValidateMap request to get a mapfile validation output.  
[MAP-176](https://dycominc.atlassian.net/browse/MAP-176)  
**9a.** Create a token using `list_map_files` as the resource:  
```json  
{
  "appkey": "insert-your-appkey-here",
  "resource": "list_map_files"
}

9b. Add the following mapfile contents to the raw body of the request:

MAP
            NAME "sample"
            LAYER
                NAME "test"
                STATUS DEFAULT
                DATA "SELECT GEOM FROM TABLE"
                TYPE LINE
            END
        END

9c. Using the header X-API-KEY with the value from step 9a, send a message using the following URL:

https://maptimus.certusview.com/api/v2/mapfile?service=MFS&version=1.1.0&request=ValidateMap

9d. After sending a message, the response should look like this:

{
    "response": "success",
    "validation_errors": []
}

10. Test the MFS GetFile request to get a mapfile output.

MAP-176
11a. Create a token using get_file as the resource:

{
  "appkey": "insert-your-appkey-here",
  "resource": "get_file"
}

10b. Using the header X-API-KEY with the value from step 10a, send a message using the following URL:

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.1.0&request=GetFile&project=shared&file=shared.sym

10c. After sending a message, the response should look like this:

SYMBOLSET

    SYMBOL
        NAME "interstate"
        TYPE pixmap
        IMAGE "interstate.png"
    END

    SYMBOL
        NAME 'tie'
        TYPE vector
        POINTS
            0 0
            0 2
        END
        ANCHORPOINT 0 0.5
    END

    SYMBOL
        NAME "dot"
        TYPE ellipse
        FILLED true
        POINTS
            1 1
        END
    END
END

11. Test the MFS PutFile request to upload a file to the server.

MAP-176
11a. Create a token using put_file as the resource:

{
  "appkey": "insert-your-appkey-here",
  "resource": "put_file"
}

11b. Add the following file to key's value body of the request:

Key is file and test_fpa.png is the Value

11c. Using the header X-API-KEY with the value from step 11a, send a message using the following URL:

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.2.0&request=PutFile&project=tests

11d. After sending a message, the response should look like this:
json { "response": "success", "message": "test_fpa.png was created" }

12. Test the MFS DeleteFile request to delete a file on the server.

MAP-176
12a. Create a token using delete_file as the resource:

{
  "appkey": "insert-your-appkey-here",
  "resource": "delete_file"
}

12b. Add the following file to key's value body of the request:

Key is file and test_fpa.png is the Value

12c. Using the header X-API-KEY with the value from step 12a, send a message using the following URL:

https://maptimus.certusview.com/api/v2/mapfile?service=mfs&version=1.2.0&request=DeleteFile&project=tests&file=test_fpa.png

12d. After sending a message, the response should look like this:
json { "response": "success", "message": "file deleted" }