mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 02:11:10 +00:00
Implements tests for commit bfa7b190b2
Covers the four consumption lifecycle Web proxy endpoints with unit, integration and security tests and their DTO and request fixtures. Changes the report progress Web route from POST to PUT, matching the upstream API, and updates the music player and the book reader to send that verb.
This commit is contained in:
1 parent
1afb078efc
commit
d3b4eec630
22 files changed
+3108
-5
No files matched your search
+1
-1
@@ -36,7 +36,7 @@ public class ReportConsumptionProgressEndpoint : BaseEndpoint<ReportConsumptionP
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.POST);
|
||||
Verbs(Http.PUT);
|
||||
Routes(WebRoutes.MediaConsumption.REPORT_CONSUMPTION_PROGRESS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("MediaConsumption"));
|
||||
|
||||
+3
-2
@@ -326,7 +326,8 @@
|
||||
if (token && token.value)
|
||||
headers['RequestVerificationToken'] = token.value;
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
// The progress route is a PUT, unlike the start, complete and stop routes of the same lifecycle.
|
||||
method: options.method || 'POST',
|
||||
headers: headers,
|
||||
body: JSON.stringify(payload ?? {}),
|
||||
signal: abortController === null ? undefined : abortController.signal,
|
||||
@@ -478,7 +479,7 @@
|
||||
const payload = session.pendingProgressPayload;
|
||||
session.pendingProgressPayload = null;
|
||||
const url = buildConsumptionRecordUrl(reportConsumptionProgressUrlTemplate, session.recordId);
|
||||
await sendConsumptionRequestAsync(url, payload);
|
||||
await sendConsumptionRequestAsync(url, payload, { method: 'PUT' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.debug('Book reader: a consumption progress report could not be sent.', error);
|
||||
|
||||
@@ -3883,6 +3883,7 @@
|
||||
* @param {boolean} [options.keepalive=false] - True to let the browser finish the request after the page is gone, used by the unload flush.
|
||||
* @param {AbortSignal} [options.signal] - An optional signal that cancels the request when the player supersedes or stops it.
|
||||
* @param {string} [options.label] - The description used in the failure log, so a caller such as the queue reports its own request.
|
||||
* @param {string} [options.method='POST'] - The HTTP method of the request, used by a caller whose route only accepts another verb.
|
||||
* @returns {Promise<*|null|undefined|Object>} The unwrapped data, null when the endpoint answered without data, undefined when the request failed, or the REDIRECTED marker when the session expired and the page is navigating away.
|
||||
*/
|
||||
async postJsonAsync(url, data, options = {}) {
|
||||
@@ -3905,7 +3906,7 @@
|
||||
if (token && token.value)
|
||||
headers['RequestVerificationToken'] = token.value;
|
||||
const response = await fetch(requestUrl, {
|
||||
method: 'POST',
|
||||
method: options.method || 'POST',
|
||||
headers: headers,
|
||||
body: JSON.stringify(data ?? {}),
|
||||
signal: options.signal,
|
||||
@@ -4201,7 +4202,8 @@
|
||||
if (!route)
|
||||
return;
|
||||
const payload = this.buildConsumptionPayload(session, 'progress');
|
||||
const options = { label: 'a consumption progress request' };
|
||||
// The progress route is a PUT, unlike the start, complete and stop routes of the same lifecycle.
|
||||
const options = { label: 'a consumption progress request', method: 'PUT' };
|
||||
if (typeof AbortController === 'function') {
|
||||
abortController = new AbortController();
|
||||
options.signal = abortController.signal;
|
||||
|
||||
Reference in new issue
Block a user