Skip to content

Commit efc3402

Browse files
author
Pierre DE SOYRES
committed
fix(network-group): use text/plain Accept header for WireGuard configuration endpoint
The endpoint returns a WireGuard configuration file as plain text, not JSON.
1 parent c46bec6 commit efc3402

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

esm/api/v4/network-group.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export function getNetworkGroupWireGuardConfiguration(params) {
255255
return Promise.resolve({
256256
method: 'get',
257257
url: `/v4/networkgroups/organisations/${params.ownerId}/networkgroups/${params.networkGroupId}/peers/${params.peerId}/wireguard/configuration`,
258-
headers: { Accept: 'application/json' },
258+
headers: { Accept: 'text/plain' },
259259
// no query params
260260
// no body
261261
});

src/clients/cc-api/commands/network-group/get-network-group-wireguard-configuration-command.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @import { GetNetworkGroupWireguardConfigurationCommandInput, GetNetworkGroupWireguardConfigurationCommandOutput } from './get-network-group-wireguard-configuration-command.types.js';
33
*/
4-
import { get } from '../../../../lib/request/request-params-builder.js';
4+
import { HeadersBuilder } from '../../../../lib/request/headers-builder.js';
55
import { safeUrl } from '../../../../lib/utils.js';
66
import { CcApiSimpleCommand } from '../../lib/cc-api-command.js';
77

@@ -15,9 +15,11 @@ import { CcApiSimpleCommand } from '../../lib/cc-api-command.js';
1515
export class GetNetworkGroupWireguardConfigurationCommand extends CcApiSimpleCommand {
1616
/** @type {CcApiSimpleCommand<GetNetworkGroupWireguardConfigurationCommandInput, GetNetworkGroupWireguardConfigurationCommandOutput>['toRequestParams']} */
1717
toRequestParams(params) {
18-
return get(
19-
safeUrl`/v4/networkgroups/organisations/${params.ownerId}/networkgroups/${params.networkGroupId}/peers/${params.peerId}/wireguard/configuration`,
20-
);
18+
return {
19+
method: 'GET',
20+
url: safeUrl`/v4/networkgroups/organisations/${params.ownerId}/networkgroups/${params.networkGroupId}/peers/${params.peerId}/wireguard/configuration`,
21+
headers: new HeadersBuilder().acceptTextPlain().build(),
22+
};
2123
}
2224

2325
/** @type {CcApiSimpleCommand<?, ?>['getEmptyResponsePolicy']} */

test/e2e/clients/cc-api/commands/network-group-commands.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,7 @@ describe('network-group commands', function () {
223223
}),
224224
);
225225

226-
expect(response.ngId).to.equal(createdNetworkGroup.id);
227-
expect(response.peerId).to.equal(externalPeer.id);
228-
expect(response.version).to.be.a('number');
226+
expect(response).to.be.a('string');
229227
});
230228

231229
it('should get network group peer wireguard config url', async () => {

0 commit comments

Comments
 (0)