geoserver-node-client 0.0.6 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/demo/index.js DELETED
@@ -1,188 +0,0 @@
1
- import GeoServerRestClient from '../geoserver-rest-client.js';
2
-
3
- const url = 'http://localhost:8080/geoserver/rest/';
4
- const user = 'admin';
5
- const pw = 'geoserver';
6
- const grc = new GeoServerRestClient(url, user, pw);
7
-
8
- // const ws = 'test';
9
- // const sldBody = '<?xml version="1.0" encoding="UTF-8"?>\n<StyledLayerDescriptor version="1.0.0" \n xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" \n xmlns="http://www.opengis.net/sld" \n xmlns:ogc="http://www.opengis.net/ogc" \n xmlns:xlink="http://www.w3.org/1999/xlink" \n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n <NamedLayer>\n <Name>default_line</Name>\n <UserStyle>\n <Title>Default Line</Title>\n <Abstract>A sample style that draws a line</Abstract>\n <FeatureTypeStyle>\n <Rule>\n <Name>rule1</Name>\n <Title>Blue Line</Title>\n <Abstract>A solid blue line with a 1 pixel width</Abstract>\n <LineSymbolizer>\n <Stroke>\n <CssParameter name="stroke">#0000FF</CssParameter>\n </Stroke>\n </LineSymbolizer>\n </Rule>\n </FeatureTypeStyle>\n </UserStyle>\n </NamedLayer>\n</StyledLayerDescriptor>\n';
10
- // const recursive = true;
11
-
12
- // GENERAL
13
-
14
- grc.exists().then(gsExists => {
15
- console.log('GeoServer REST exists', gsExists);
16
- });
17
- grc.getVersion().then(versionInfo => {
18
- console.log('GeoServer REST version info', prettyJson(versionInfo));
19
- });
20
-
21
- // NAMESPACES
22
-
23
- // const nsPrefix = 'example-namespace';
24
- // const nsUri = 'http://www.example.com'
25
- // grc.namespaces.create(nsPrefix, nsUri).then(retVal => {
26
- // console.log('Created GeoServer NS', prettyJson(retVal));
27
- // });
28
- // grc.namespaces.getAll().then(gsNamespaces => {
29
- // console.log('GeoServer All NS', prettyJson(gsNamespaces));
30
- // });
31
- // grc.namespaces.get(nsPrefix).then(gsNamespaces => {
32
- // console.log('GeoServer NS', prettyJson(gsNamespaces));
33
- // });
34
- // grc.namespaces.delete(nsPrefix).then(gsNamespaces => {
35
- // console.log('Deleted GeoServer NS', prettyJson(gsNamespaces));
36
- // });
37
-
38
- // WORKSPACES
39
-
40
- // grc.workspaces.getAll().then(gsWorkspaces => {
41
- // console.log('GeoServer All WS', prettyJson(gsWorkspaces));
42
- // });
43
- // grc.workspaces.create(ws).then(retVal => {
44
- // console.log('Created GeoServer WS', prettyJson(retVal));
45
- // });
46
- // grc.workspaces.delete(ws, recursive).then(retVal => {
47
- // console.log('Deleted GeoServer WS', prettyJson(retVal));
48
- // });
49
-
50
- // DATASTORES
51
-
52
- // grc.datastores.getDataStores(ws).then(gsDataStores => {
53
- // console.log('GeoServer data stores in WS', ws, prettyJson(gsDataStores));
54
- // });
55
- // grc.datastores.getCoverageStores(ws).then(gsCovStores => {
56
- // console.log('GeoServer coverage stores in WS', ws, prettyJson(gsCovStores));
57
- // });
58
- // grc.datastores.getWmsStores(ws).then(gsWmsStores => {
59
- // console.log('GeoServer WMS stores in WS', ws, prettyJson(gsWmsStores));
60
- // });
61
- // grc.datastores.getWmtsStores(ws).then(gsWmsStores => {
62
- // console.log('GeoServer WMTS stores in WS', ws, prettyJson(gsWmsStores));
63
- // });
64
- // grc.datastores.getDataStore(ws, 'foo').then(gsStore => {
65
- // console.log('GeoServer data store ', prettyJson(gsStore));
66
- // });
67
- // grc.datastores.getCoverageStore(ws, 'foo').then(gsStore => {
68
- // console.log('GeoServer coverage store ', prettyJson(gsStore));
69
- // });
70
- // grc.datastores.getWmsStore(ws, 'foo').then(gsStore => {
71
- // console.log('GeoServer wms store ', prettyJson(gsStore));
72
- // });
73
- // grc.datastores.getWmtsStore(ws, 'foo').then(gsStore => {
74
- // console.log('GeoServer wmts store ', prettyJson(gsStore));
75
- // });
76
- // const geotiff = '/opt/STK10_32354_5670_6_nwfarbe.tif';
77
- // grc.datastores.createGeotiffFromFile('test', 'testDs', 'HymptyLayer', 'DumptyTitle', geotiff).then(gsWmsStores => {
78
- // console.log('GeoServer create GeoTIFF', prettyJson(gsWmsStores));
79
- // });
80
- // grc.datastores.createImageMosaicStore('image_mosaics', 'myname', '/path/to/properties.zip').then(res => {
81
- // console.log('res', res);
82
- // });
83
- // grc.datastores.deleteCoverageStore('test', 'test', true).then(gsWmsStores => {
84
- // console.log('Deleted coverage store', prettyJson(gsWmsStores));
85
- // });
86
- // const wmsUrl = 'https://ows.terrestris.de/osm/service?';
87
- // grc.datastores.createWmsStore(ws, 'testWmsDs', wmsUrl).then(retVal => {
88
- // console.log('Created WMS data store', prettyJson(retVal));
89
- // });
90
- // const wfsCapsUrl = 'https://services.meggsimum.de/geoserver/ows?service=wfs&version=1.1.0&request=GetCapabilities';
91
- // const namespaceUrl = 'http://test';
92
- // grc.datastores.createWfsStore(ws, 'testWfsDs', wfsCapsUrl, namespaceUrl, false).then(retVal => {
93
- // console.log('Created WFS data store', prettyJson(retVal));
94
- // });
95
- // grc.datastores.deleteDataStore(ws, 'testWfsDs', false).then(gsWmsStores => {
96
- // console.log('Deleted data store', prettyJson(gsWmsStores));
97
- // });
98
- // const initZipArchivePath = '/home/meggs/workspace/meggsimum/sauber/sauber-sdi-docker/geoserver_publisher/gs-img-mosaic-tpl/init.zip';
99
- // grc.datastores.createImageMosaicStore('test-cm', 'testCovStore', initZipArchivePath).then(retVal => {
100
- // console.log('Created Image Mosaic Store', retVal);
101
- // });
102
- // const gpkgPath = 'natural_earth_vector.gpkg';
103
- // grc.datastores.createGpkgStore(ws, 'testGpkgStore', gpkgPath).then(retVal => {
104
- // console.log('Created GPKG Store', retVal);
105
- // });
106
-
107
- // LAYERS
108
-
109
- // grc.layers.get('fooWs:barLayer').then(layer => {
110
- // console.log('GeoServer layer by qualified name', prettyJson(layer));
111
- // });
112
- // grc.layers.getAll().then(allLayers => {
113
- // console.log('All GeoServer layers', prettyJson(allLayers));
114
- // });
115
- // grc.layers.publishFeatureTypeDefaultDataStore(ws, 'nativeFtName', 'aTestName', 'Test Title', 'EPSG:31468', false).then(retVal => {
116
- // console.log('Created Layer', prettyJson(retVal));
117
- // });
118
- // grc.layers.publishFeatureType(ws, 'testdataStore', 'nativeFtName', 'aTestName2', 'Test Title 2', 'EPSG:31468', true).then(retVal => {
119
- // console.log('Created Layer', prettyJson(retVal));
120
- // });
121
- // const nativeBoundingBox = {
122
- // minx: 8.15,
123
- // maxx: 8.16,
124
- // miny: 50.0,
125
- // maxy: 50.1,
126
- // crs: {
127
- // '@class': 'projected',
128
- // $: 'EPSG:4326'
129
- // }
130
- // };
131
- // grc.layers.publishFeatureType(ws, 'testdataStore', 'nativeFtName', 'aTestNameBbox', 'Test Title Bbox', 'EPSG:4326', true, null, nativeBoundingBox).then(retVal => {
132
- // console.log('Created FT with explicit native BBOX', prettyJson(retVal));
133
- // });
134
- // grc.layers.publishWmsLayer(ws, 'testWmsDs', 'OSM-Overlay-WMS', 'aTestName4Wms', 'Test Title WMS', 'EPSG:900913', true).then(retVal => {
135
- // console.log('Created WMS Layer', prettyJson(retVal));
136
- // });
137
- // grc.layers.publishDbRaster(ws, 'testdataStore', 'nativeRasterName', 'a-db-raster', 'Dummy DB Raster Title', null, true).then(retVal => {
138
- // console.log('Created DB Raster Layer', prettyJson(retVal))
139
- // });
140
- // grc.layers.deleteFeatureType(ws, 'testdataStore', 'aTestName2', true).then(retVal => {
141
- // console.log('Deleted Layer', prettyJson(retVal))
142
- // });
143
- // grc.layers.enableTimeCoverage(ws, 'testDs', 'HymptyLayer', 'DISCRETE_INTERVAL', 3600000, 'MAXIMUM').then(retVal => {
144
- // console.log('Enabled time for layer', prettyJson(retVal))
145
- // });
146
- // grc.layers.getCoverage(ws, 'testCovStore', 'testCoverage').then(cov => {
147
- // console.log(cov.coverage);
148
- // });
149
-
150
- // STYLES
151
-
152
- // grc.styles.getDefaults().then(gsWorkspaces => {
153
- // console.log('GeoServer default styles', prettyJson(gsWorkspaces));
154
- // });
155
- // grc.styles.getInWorkspace(ws).then(gsWorkspaces => {
156
- // console.log('GeoServer styles for WS', prettyJson(gsWorkspaces));
157
- // });
158
- // grc.styles.getAllWorkspaceStyles().then(allGsWsStyles => {
159
- // console.log('GeoServer all WS styles', prettyJson(allGsWsStyles));
160
- // });
161
- // grc.styles.getAll().then(allGsStyles => {
162
- // console.log('GeoServer all styles', prettyJson(allGsStyles));
163
- // });
164
- // grc.styles.publish(ws, 'testStyle3', sldBody).then(retVal => {
165
- // console.log('Publish GeoServer style', retVal);
166
- // });
167
-
168
- // IMAGEMOSAIC
169
-
170
- // grc.imagemosaics.getGranules('imagemosaic_test', 'testCovStore', 'testCov').then(retVal => {
171
- // console.log('Get Granules Image Mosaic', retVal);
172
- // });
173
- // const filePathCoverages = 'file:///opt/raster_data'
174
- // grc.imagemosaics.harvestGranules('imagemosaic_test', 'testCovStore', filePathCoverages).then(retVal => {
175
- // console.log('Harveset Granules Image Mosaic', retVal);
176
- // });
177
- // const coverageToAdd = 'file:///opt/raster_data/a.tif'
178
- // grc.imagemosaics.addGranuleByServerFile('imagemosaic_test', 'testCovStore', coverageToAdd).then(retVal => {
179
- // console.log('Add Granule by Server File', retVal);
180
- // });
181
- // const coverageToDelete = '/opt/raster_data/a.tif';
182
- // grc.imagemosaics.deleteSingleGranule('imagemosaic_test', 'testCovStore', 'testCov', coverageToDelete).then(retVal => {
183
- // console.log('Deleting Granule', retVal);
184
- // });
185
-
186
- function prettyJson (obj) {
187
- return JSON.stringify(obj, null, 2);
188
- }
package/release-it.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "hooks": {
3
- "before:init": ["npm run lint", "npm test"]
4
- },
5
- "github": {
6
- "release": true
7
- }
8
- }
Binary file
Binary file
package/test/test.js DELETED
@@ -1,491 +0,0 @@
1
- /* global describe:false, it:false, before:false, after:false */
2
- /* eslint-disable no-unused-expressions */
3
- import { expect } from 'chai';
4
- import GeoServerRestClient from '../geoserver-rest-client.js';
5
-
6
- const url = 'http://localhost:8080/geoserver/rest/';
7
- const user = 'admin';
8
- const pw = 'geoserver';
9
- const grc = new GeoServerRestClient(url, user, pw);
10
-
11
- const workSpace = 'my-workspace';
12
-
13
- const nameSpace = 'my-namespace';
14
- const nameSpaceUri = 'http://www.example.com';
15
-
16
- const geoServerVersion = process.env.GEOSERVER_VERSION;
17
-
18
- describe('Basic GeoServer', () => {
19
- it('should exist', async () => {
20
- const result = await grc.exists();
21
- expect(result).to.be.true;
22
- });
23
-
24
- it('returns correct version', async () => {
25
- const result = await grc.getVersion();
26
- expect(result.about.resource[0].Version).to.equal(geoServerVersion);
27
- })
28
- });
29
-
30
- describe('Settings', () => {
31
- after(async () => {
32
- await grc.settings.updateSettings({
33
- global: {
34
- settings: {
35
- verbose: true
36
- }
37
- }
38
- });
39
- await grc.settings.updateProxyBaseUrl('');
40
- });
41
-
42
- it('returns settings object', async () => {
43
- const settings = await grc.settings.getSettings();
44
- expect(settings).to.not.be.false;
45
- expect(settings.global.settings.charset).to.not.be.false;
46
- })
47
-
48
- it('updates settings object', async () => {
49
- const settingsJson = {
50
- global: {
51
- settings: {
52
- verbose: false
53
- }
54
- }
55
- };
56
- const updateOk = await grc.settings.updateSettings(settingsJson);
57
- expect(updateOk).to.be.true;
58
-
59
- const settings = await grc.settings.getSettings();
60
- expect(settings.global.settings.verbose).to.equal(settingsJson.global.settings.verbose);
61
- })
62
-
63
- it('updates proxyBaseUrl', async () => {
64
- const url = 'http://foobar.de/geoserver';
65
- const updateOk = await grc.settings.updateProxyBaseUrl(url);
66
- expect(updateOk).to.be.true;
67
-
68
- const settings = await grc.settings.getSettings();
69
- expect(settings.global.settings.proxyBaseUrl).to.equal(url);
70
- })
71
-
72
- it('returns contact information', async () => {
73
- const contactInfo = await grc.settings.getContactInformation();
74
- expect(contactInfo).to.not.be.false;
75
- })
76
-
77
- it('can update contact information', async () => {
78
- const address = 'Unter den Linden';
79
- const city = 'Berlin';
80
- const country = 'Deutschland';
81
- const postalCode = 123445;
82
- const state = 'Berlin';
83
- const email = 'example email address';
84
- const organization = 'A organization';
85
- const contactPerson = 'My contact persion';
86
- const phoneNumber = 1231234234123;
87
-
88
- const result = await grc.settings.updateContactInformation(address, city, country, postalCode, state, email, organization, contactPerson, phoneNumber);
89
- expect(result).to.be.true;
90
-
91
- const contactResponse = await grc.settings.getContactInformation();
92
-
93
- // test two sample values
94
- expect(address).to.equal(contactResponse.contact.address);
95
- expect(state).to.equal(contactResponse.contact.addressState);
96
- })
97
- });
98
-
99
- describe('Workspace', () => {
100
- it('has no workspace', async () => {
101
- const gsWorkspaces = await grc.workspaces.getAll();
102
- expect(gsWorkspaces.workspaces).to.equal('');
103
- });
104
-
105
- it('creates one workspace', async () => {
106
- const result = await grc.workspaces.create(workSpace);
107
- expect(result).to.equal(workSpace);
108
- });
109
-
110
- it('has one workspace', async () => {
111
- const gsWorkspaces = await grc.workspaces.getAll();
112
- expect(gsWorkspaces.workspaces.workspace.length).to.equal(1);
113
- expect(gsWorkspaces.workspaces.workspace[0].name).to.equal(workSpace);
114
- });
115
-
116
- it('query dedicated workspace', async () => {
117
- const gsWorkspace = await grc.workspaces.get(workSpace);
118
- expect(gsWorkspace.workspace.name).to.equal(workSpace);
119
- });
120
-
121
- it('delete workspace', async () => {
122
- const recursive = true;
123
- const result = await grc.workspaces.delete(workSpace, recursive);
124
- expect(result).to.be.true;
125
- });
126
-
127
- it('has no workspace', async () => {
128
- const gsWorkspaces = await grc.workspaces.getAll();
129
- expect(gsWorkspaces.workspaces).to.equal('');
130
- });
131
- });
132
-
133
- describe('Namespace', () => {
134
- it('has no namespaces', async () => {
135
- const gsNamespaces = await grc.namespaces.getAll();
136
- expect(gsNamespaces.namespaces).to.equal('');
137
- });
138
-
139
- it('creates one namespace', async () => {
140
- const result = await grc.namespaces.create(nameSpace, nameSpaceUri);
141
- expect(result).to.equal(nameSpace);
142
- });
143
-
144
- it('has one namespace', async () => {
145
- const gsNameSpaces = await grc.namespaces.getAll();
146
- expect(gsNameSpaces.namespaces.namespace.length).to.equal(1);
147
- expect(gsNameSpaces.namespaces.namespace[0].name).to.equal(nameSpace);
148
- });
149
-
150
- it('query dedicated namespace', async () => {
151
- const gsNameSpace = await grc.namespaces.get(nameSpace);
152
- expect(gsNameSpace.namespace.prefix).to.equal(nameSpace);
153
- expect(gsNameSpace.namespace.uri).to.equal(nameSpaceUri);
154
- });
155
-
156
- it('delete namespace', async () => {
157
- const result = await grc.namespaces.delete(nameSpace);
158
- expect(result).to.be.true;
159
- });
160
-
161
- it('has no namespace', async () => {
162
- const gsNameSpaces = await grc.namespaces.getAll();
163
- expect(gsNameSpaces.namespaces).to.equal('');
164
- });
165
- });
166
-
167
- describe('Datastore', () => {
168
- let createdWorkSpace;
169
-
170
- before('create workspace', async () => {
171
- createdWorkSpace = await grc.workspaces.create(workSpace);
172
- });
173
-
174
- // TODO: test PostGIS store
175
- // TODO: test image mosaic
176
- // TODO: test WMTS-Stores
177
-
178
- // TODO: copy test data to GeoServer before
179
- it('can create GeoTIFF', async () => {
180
- const geotiff = 'test/sample_data/world.geotiff'
181
- const result = await grc.datastores.createGeotiffFromFile(
182
- workSpace,
183
- 'my-rasterstore',
184
- 'my-raster-name',
185
- 'My Raster Title',
186
- geotiff);
187
- expect(result).to.not.be.false;
188
- });
189
-
190
- it('can create a WMS Store', async () => {
191
- // TODO: make sure the WMS actually exists
192
- const wmsUrl = 'https://ows.terrestris.de/osm/service?';
193
- const result = await grc.datastores.createWmsStore(
194
- workSpace,
195
- 'my-wms-datastore',
196
- wmsUrl);
197
- expect(result).to.not.be.false;
198
- });
199
-
200
- it('can create a WFS Store', async () => {
201
- // TODO: make sure the WFS actually exists
202
- const wfsCapsUrl = 'https://ows-demo.terrestris.de/geoserver/osm/wfs?service=wfs&version=1.1.0&request=GetCapabilities';
203
- const namespaceUrl = 'http://test';
204
- const result = await grc.datastores.createWfsStore(
205
- workSpace,
206
- 'my-wfs-datastore',
207
- wfsCapsUrl,
208
- namespaceUrl);
209
- expect(result).to.be.true;
210
- });
211
-
212
- // TODO: copy test data to GeoServer
213
- it('can create a GeoPackage Store', async () => {
214
- const gpkg = 'test/sample_data/iceland.gpkg'
215
- const result = await grc.datastores.createGpkgStore(
216
- workSpace,
217
- 'my-gpkg-store',
218
- gpkg)
219
- expect(result).to.be.true;
220
- });
221
-
222
- it('can retrive the data stores', async () => {
223
- const result = await grc.datastores.getDataStores(workSpace);
224
- const dataStores = result.dataStores.dataStore;
225
- expect(dataStores.length).to.equal(2);
226
- });
227
-
228
- it('can retrive the coverage stores', async () => {
229
- const result = await grc.datastores.getCoverageStores(workSpace);
230
- const coverageStores = result.coverageStores.coverageStore;
231
- expect(coverageStores.length).to.equal(1);
232
- });
233
-
234
- it('can retrive the WMS stores', async () => {
235
- const result = await grc.datastores.getWmsStores(workSpace);
236
- const wmsStores = result.wmsStores.wmsStore;
237
- expect(wmsStores.length).to.equal(1);
238
- });
239
-
240
- after('delete Workspace', async () => {
241
- const recursive = true;
242
- await grc.workspaces.delete(createdWorkSpace, recursive);
243
- });
244
- });
245
-
246
- describe('Layer', () => {
247
- let createdWorkSpace;
248
- const wmsLayerName = 'my-wms-layer-name';
249
- const featureLayerName = 'my-feature-layer-name'
250
- const wfsDataStore = 'my-wfs-datastore';
251
-
252
- before('create workspace', async () => {
253
- createdWorkSpace = await grc.workspaces.create(workSpace);
254
- });
255
-
256
- it('can publish a FeatureType', async () => {
257
- const wfsCapsUrl = 'https://ows-demo.terrestris.de/geoserver/osm/wfs?service=wfs&version=1.1.0&request=GetCapabilities';
258
- const namespaceUrl = 'http://test';
259
- const dataStoreResult = await grc.datastores.createWfsStore(
260
- workSpace,
261
- wfsDataStore,
262
- wfsCapsUrl,
263
- namespaceUrl
264
- );
265
- expect(dataStoreResult).to.be.true;
266
-
267
- const result = await grc.layers.publishFeatureType(
268
- workSpace,
269
- wfsDataStore,
270
- 'osm_osm-country-borders',
271
- featureLayerName,
272
- 'My Feature title',
273
- 'EPSG:4326',
274
- true,
275
- 'Sample Abstract'
276
- );
277
- expect(result).to.be.true;
278
- });
279
-
280
- it('can publish a FeatureType with explicit native BBOX', async () => {
281
- const ftName = featureLayerName + '_native_bbox';
282
- const nativeBoundingBox = {
283
- minx: 8.15,
284
- maxx: 8.16,
285
- miny: 50.0,
286
- maxy: 50.1
287
- };
288
-
289
- const result = await grc.layers.publishFeatureType(
290
- workSpace,
291
- wfsDataStore,
292
- 'osm_osm-country-borders',
293
- ftName,
294
- 'My Feature title native BBOX',
295
- 'EPSG:4326',
296
- true,
297
- 'Sample Abstract native BBOX',
298
- nativeBoundingBox
299
- );
300
- expect(result).to.be.true;
301
- });
302
-
303
- it('can publish a WMS layer', async () => {
304
- // TODO: make sure WMS url is still working
305
- const wmsUrl = 'https://ows.terrestris.de/osm/service?';
306
- const wmsDataStore = 'my-wms-datastore';
307
- const wmsStoreResult = await grc.datastores.createWmsStore(
308
- workSpace,
309
- wmsDataStore,
310
- wmsUrl);
311
-
312
- expect(wmsStoreResult).to.be.true;
313
- const result = await grc.layers.publishWmsLayer(
314
- workSpace,
315
- wmsDataStore,
316
- 'OSM-Overlay-WMS',
317
- wmsLayerName,
318
- 'My WMS Title',
319
- 'EPSG:900913',
320
- true,
321
- 'Sample Abstract'
322
- );
323
- expect(result).to.be.true;
324
- })
325
-
326
- it('can modify the attribution', async () => {
327
- const attributionText = 'sample attribution';
328
- const attributionLink = 'http://www.example.com';
329
-
330
- const attributionResult = await grc.layers.modifyAttribution(`${workSpace}:${wmsLayerName}`, attributionText, attributionLink);
331
-
332
- const layerProperties = await grc.layers.get(`${workSpace}:${wmsLayerName}`);
333
-
334
- expect(attributionResult).to.be.true;
335
- expect(layerProperties.layer.attribution.title).to.equal(attributionText);
336
- expect(layerProperties.layer.attribution.href).to.equal(attributionLink);
337
- })
338
-
339
- it('can get retrieve all layers', async () => {
340
- const result = await grc.layers.getAll();
341
- expect(result.layers.layer.length).to.equal(3);
342
- })
343
-
344
- it('can get a layer by qualified name', async () => {
345
- const nonExistentLayer = 'non-existent-layer';
346
- let result = await grc.layers.get(workSpace + ':' + nonExistentLayer);
347
- expect(result).to.be.false;
348
-
349
- result = await grc.layers.get(workSpace + ':' + wmsLayerName);
350
- expect(result.layer.name).to.equal(wmsLayerName);
351
- })
352
-
353
- // TODO: publishFeatureTypeDefaultDataStore
354
-
355
- it('can delete a feature type', async () => {
356
- const recursive = true;
357
- const result = await grc.layers.deleteFeatureType(
358
- workSpace,
359
- wfsDataStore,
360
- featureLayerName,
361
- recursive
362
- );
363
- expect(result).to.be.true;
364
- })
365
-
366
- it('has function to query coverages', async () => {
367
- // query a non-existing coverage to check that the function exists
368
- // TODO test valid response once we have coverages in test setup
369
- const result = await grc.layers.getCoverage(workSpace, 'testCovStore', 'testCoverage');
370
- expect(result).to.be.false;
371
- })
372
-
373
- after('delete Workspace', async () => {
374
- const recursive = true;
375
- await grc.workspaces.delete(createdWorkSpace, recursive);
376
- });
377
- });
378
-
379
- describe('style', () => {
380
- let createdWorkSpace;
381
- const styleName = 'my-style-name';
382
- const featureLayerName = 'my-feature-layer-name'
383
- const wfsDataStore = 'my-wfs-datastore';
384
-
385
- before('create workspace', async () => {
386
- createdWorkSpace = await grc.workspaces.create(workSpace);
387
- });
388
-
389
- it('can get default styles', async () => {
390
- const result = await grc.styles.getDefaults();
391
- expect(result.styles.style.length).to.equal(5)
392
- })
393
-
394
- it('can publish a style', async () => {
395
- const sldBody = '<?xml version="1.0" encoding="UTF-8"?>\n<StyledLayerDescriptor version="1.0.0" \n xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" \n xmlns="http://www.opengis.net/sld" \n xmlns:ogc="http://www.opengis.net/ogc" \n xmlns:xlink="http://www.w3.org/1999/xlink" \n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n <NamedLayer>\n <Name>default_line</Name>\n <UserStyle>\n <Title>Default Line</Title>\n <Abstract>A sample style that draws a line</Abstract>\n <FeatureTypeStyle>\n <Rule>\n <Name>rule1</Name>\n <Title>Blue Line</Title>\n <Abstract>A solid blue line with a 1 pixel width</Abstract>\n <LineSymbolizer>\n <Stroke>\n <CssParameter name="stroke">#0000FF</CssParameter>\n </Stroke>\n </LineSymbolizer>\n </Rule>\n </FeatureTypeStyle>\n </UserStyle>\n </NamedLayer>\n</StyledLayerDescriptor>\n';
396
-
397
- const result = await grc.styles.publish(
398
- workSpace,
399
- styleName,
400
- sldBody
401
- );
402
- expect(result).to.be.true;
403
- })
404
-
405
- it('can get all styles', async () => {
406
- const result = await grc.styles.getAll();
407
- expect(result.length).to.equal(6)
408
- })
409
-
410
- it('can assign a style to a layer', async () => {
411
- const wfsCapsUrl = 'https://ows-demo.terrestris.de/geoserver/osm/wfs?service=wfs&version=1.1.0&request=GetCapabilities';
412
- const namespaceUrl = 'http://test';
413
-
414
- const dataStoreResult = await grc.datastores.createWfsStore(
415
- workSpace,
416
- wfsDataStore,
417
- wfsCapsUrl,
418
- namespaceUrl
419
- );
420
- expect(dataStoreResult).to.be.true;
421
-
422
- const layerResult = await grc.layers.publishFeatureType(
423
- workSpace,
424
- wfsDataStore,
425
- 'osm_osm-country-borders',
426
- featureLayerName,
427
- 'My Feature title',
428
- 'EPSG:4326',
429
- true
430
- );
431
- expect(layerResult).to.be.true;
432
-
433
- const qualifiedName = workSpace + ':' + featureLayerName;
434
- const workspaceStyle = workSpace;
435
- const isDefaultStyle = true;
436
- const result = await grc.styles.assignStyleToLayer(qualifiedName, styleName, workspaceStyle, isDefaultStyle);
437
- expect(result).to.be.true;
438
- });
439
-
440
- it('can get style information', async () => {
441
- const result = await grc.styles.getStyleInformation(styleName, workSpace);
442
- expect(result.style.name).to.equal(styleName);
443
- })
444
-
445
- it('can get styles in specific workspace', async () => {
446
- const result = await grc.styles.getInWorkspace(workSpace);
447
- expect(result.styles.style.length).to.equal(1);
448
- })
449
-
450
- it('can get styles in all workspaces', async () => {
451
- const result = await grc.styles.getAllWorkspaceStyles();
452
- expect(result.length).to.equal(1);
453
- })
454
-
455
- after('delete Workspace', async () => {
456
- const recursive = true;
457
- await grc.workspaces.delete(createdWorkSpace, recursive);
458
- });
459
- });
460
-
461
- describe('Security', () => {
462
- let createdWorkSpace;
463
-
464
- const dummyUser = 'dummyUser';
465
- const dummyPassword = 'dummyPassword';
466
-
467
- before('create workspace', async () => {
468
- createdWorkSpace = await grc.workspaces.create(workSpace);
469
- });
470
-
471
- it('can create a user', async () => {
472
- const result = await grc.security.createUser(dummyUser, dummyPassword);
473
- expect(result).to.be.true;
474
- })
475
-
476
- it('can associate a user role', async () => {
477
- const result = await grc.security.associateUserRole(dummyUser, 'ADMIN');
478
- expect(result).to.be.true;
479
- })
480
-
481
- it('can update a user', async () => {
482
- const enabled = false;
483
- const result = await grc.security.updateUser(dummyUser, dummyPassword, enabled);
484
- expect(result).to.be.true;
485
- })
486
-
487
- after(async () => {
488
- const recursive = true;
489
- await grc.workspaces.delete(createdWorkSpace, recursive);
490
- });
491
- });