mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Return 201 when creating new resources
This commit is contained in:
@@ -105,7 +105,8 @@ describe.each(configs)('A dynamic pod server with template config %s', (template
|
||||
},
|
||||
body: 'this is new data!',
|
||||
});
|
||||
expect(res.status).toBe(205);
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.headers.get('location')).toBe(`${podUrl}test`);
|
||||
|
||||
res = await fetch(`${podUrl}test`, {
|
||||
headers: {
|
||||
|
||||
@@ -84,7 +84,7 @@ describe.each(stores)('An LDP handler with auth using %s', (name, { storeConfig,
|
||||
|
||||
// PUT
|
||||
const document = `${baseUrl}test.txt`;
|
||||
await putResource(document, { contentType: 'text/plain', body: 'TESTDATA' });
|
||||
await putResource(document, { contentType: 'text/plain', body: 'TESTDATA', exists: false });
|
||||
|
||||
// GET
|
||||
const response = await getResource(document);
|
||||
|
||||
@@ -110,7 +110,7 @@ describe.each(stores)('An LDP handler allowing all requests %s', (name, { storeC
|
||||
await expect(response.text()).resolves.toBe('TESTFILE0');
|
||||
|
||||
// PUT
|
||||
await putResource(documentUrl, { contentType: 'text/plain', body: 'TESTFILE1' });
|
||||
await putResource(documentUrl, { contentType: 'text/plain', body: 'TESTFILE1', exists: true });
|
||||
|
||||
// GET
|
||||
response = await getResource(documentUrl, {}, { contentType: 'text/plain' });
|
||||
@@ -253,7 +253,8 @@ describe.each(stores)('An LDP handler allowing all requests %s', (name, { storeC
|
||||
},
|
||||
body: createReadStream(joinFilePath(__dirname, '../assets/testimage.png')) as any,
|
||||
});
|
||||
expect(response.status).toBe(205);
|
||||
expect(response.status).toBe(201);
|
||||
expect(response.headers.get('location')).toBe(documentUrl);
|
||||
await expect(response.text()).resolves.toHaveLength(0);
|
||||
|
||||
// GET
|
||||
@@ -291,7 +292,8 @@ describe.each(stores)('An LDP handler allowing all requests %s', (name, { storeC
|
||||
headers: { 'content-length': '0', 'content-type': 'text/turtle' },
|
||||
body: '',
|
||||
});
|
||||
expect(response.status).toBe(205);
|
||||
expect(response.status).toBe(201);
|
||||
expect(response.headers.get('location')).toBe(documentUrl);
|
||||
|
||||
// GET
|
||||
await getResource(documentUrl);
|
||||
@@ -312,7 +314,7 @@ describe.each(stores)('An LDP handler allowing all requests %s', (name, { storeC
|
||||
'INSERT {<http://test.com/s3> <http://test.com/p3> <http://test.com/o3>}',
|
||||
'WHERE {}',
|
||||
].join('\n');
|
||||
await patchResource(documentUrl, query);
|
||||
await patchResource(documentUrl, query, true);
|
||||
|
||||
// PATCH using a content-type header with charset
|
||||
const query2 = [ 'DELETE { <http://test.com/s2> <http://test.com/p2> <http://test.com/o2> }',
|
||||
@@ -361,7 +363,7 @@ describe.each(stores)('An LDP handler allowing all requests %s', (name, { storeC
|
||||
'INSERT {<http://test.com/s3> <http://test.com/p3> <http://test.com/o3>}',
|
||||
'WHERE {}',
|
||||
].join('\n');
|
||||
await patchResource(documentUrl, query);
|
||||
await patchResource(documentUrl, query, true);
|
||||
|
||||
// GET
|
||||
response = await getResource(documentUrl);
|
||||
|
||||
@@ -39,7 +39,7 @@ describeIf('docker', 'A server with a RedisResourceLocker as ResourceLocker', ()
|
||||
},
|
||||
body: fileData,
|
||||
});
|
||||
expect(response.status).toBe(205);
|
||||
expect(response.status).toBe(201);
|
||||
|
||||
// Get file
|
||||
response = await fetch(fileUrl);
|
||||
@@ -64,7 +64,7 @@ describeIf('docker', 'A server with a RedisResourceLocker as ResourceLocker', ()
|
||||
'content-type': 'text/plain',
|
||||
},
|
||||
});
|
||||
expect(response.status).toBe(205);
|
||||
expect(response.status).toBe(201);
|
||||
|
||||
// GET
|
||||
response = await fetch(containerUrl);
|
||||
@@ -88,7 +88,7 @@ describeIf('docker', 'A server with a RedisResourceLocker as ResourceLocker', ()
|
||||
},
|
||||
body: fileData,
|
||||
});
|
||||
expect(response.status).toBe(205);
|
||||
expect(response.status).toBe(201);
|
||||
|
||||
// GET 4 times
|
||||
for (let i = 0; i < 4; i++) {
|
||||
|
||||
@@ -76,7 +76,8 @@ describe('A server with restricted IDP access', (): void => {
|
||||
headers: { 'content-type': 'text/turtle' },
|
||||
body: restrictedAcl,
|
||||
});
|
||||
expect(res.status).toBe(205);
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.headers.get('location')).toBe(`${baseUrl}idp/register/.acl`);
|
||||
|
||||
// Registration is now disabled
|
||||
res = await fetch(`${baseUrl}idp/register/`);
|
||||
|
||||
@@ -77,7 +77,8 @@ describe('A Solid server', (): void => {
|
||||
},
|
||||
body: '<a:b> <a:b> <a:b>.',
|
||||
});
|
||||
expect(res.status).toBe(205);
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.headers.get('location')).toBe(url);
|
||||
});
|
||||
|
||||
it('can PUT to resources.', async(): Promise<void> => {
|
||||
@@ -89,7 +90,8 @@ describe('A Solid server', (): void => {
|
||||
},
|
||||
body: '<a:b> <a:b> <a:b>.',
|
||||
});
|
||||
expect(res.status).toBe(205);
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.headers.get('location')).toBe(url);
|
||||
});
|
||||
|
||||
it('can handle PUT errors.', async(): Promise<void> => {
|
||||
|
||||
@@ -79,7 +79,8 @@ describe.each(stores)('A subdomain server with %s', (name, { storeConfig, teardo
|
||||
},
|
||||
body: 'this is new data!',
|
||||
});
|
||||
expect(res.status).toBe(205);
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.headers.get('location')).toBe(`${baseUrl}alice`);
|
||||
|
||||
res = await fetch(`${baseUrl}alice`);
|
||||
expect(res.status).toBe(200);
|
||||
@@ -136,7 +137,8 @@ describe.each(stores)('A subdomain server with %s', (name, { storeConfig, teardo
|
||||
},
|
||||
body: 'this is new data!',
|
||||
});
|
||||
expect(res.status).toBe(205);
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.headers.get('location')).toBe(`${podUrl}alice`);
|
||||
|
||||
res = await fetch(`${baseUrl}alice`, {
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user