Skip to content

Commit

Permalink
Merge pull request #641 from solita/feature/AE-2356-signing-tool-version
Browse files Browse the repository at this point in the history
AE-2356: Fetch signing tool version
  • Loading branch information
outamaa authored Dec 4, 2024
2 parents 8d09c51 + 22e86f7 commit 7edff45
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,10 @@ context('Käytönvalvonta', () => {
submitToimenpide();

now.setDate(desired);
// This works for december, setting month to January and incrementing year
now.setMonth(now.getMonth() + 1);
cy.get('[data-cy="deadline"]').contains(
`${now.getDate()}.${now.getMonth() + 2}.${now.getFullYear()}`
`${now.getDate()}.${now.getMonth() + 1}.${now.getFullYear()}`
);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified etp-front/__snapshots__/checkbox--with-label-and-checked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified etp-front/__snapshots__/checkbox--with-label-disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified etp-front/__snapshots__/checkbox--with-label.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified etp-front/__snapshots__/footer--with-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified etp-front/__snapshots__/h1--with-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified etp-front/__snapshots__/input--with-caret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified etp-front/__snapshots__/input--with-failed-validation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified etp-front/__snapshots__/input--with-required.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified etp-front/__snapshots__/input--with-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified etp-front/__snapshots__/radio--with-label.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified etp-front/__snapshots__/radio--with-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 17 additions & 11 deletions etp-front/src/pages/energiatodistus/signing/signature-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,37 @@ const mpolluxUrl = 'https://localhost:53952';
const mpolluxVersionUrl = `${mpolluxUrl}/version`;
const mpolluxSignUrl = `${mpolluxUrl}/sign`;

const signatureOptions = {
version: '1.1',
const signatureOptions = version => ({
version: version,
selector: {
keyusages: ['nonrepudiation'],
keyalgorithms: ['rsa']
},
contentType: 'data',
hashAlgorithm: 'SHA256',
signatureType: 'signature'
};
});

// Example of mPollux response can be found in etp-core/docker/mpollux/api/version
export const versionInfo = fetch => Fetch.getJson(fetch, mpolluxVersionUrl);

const getSignatureOptions = fetch =>
R.map(R.compose(signatureOptions, R.prop('version')), versionInfo(fetch));

export const isValidSignatureResponse = R.compose(
R.equals('ok'),
R.prop('status')
);

export const getSignature = R.curry((fetch, content) =>
R.compose(
R.map(R.pick(['signature', 'chain'])),
Future.filter(isValidSignatureResponse, 'error'),
Fetch.responseAsJson,
Future.encaseP(Fetch.fetchWithMethod(fetch, 'post', mpolluxSignUrl)),
R.assoc('content', R.__, signatureOptions),
R.prop('digest')
)(content)
R.chain(
R.compose(
R.map(R.pick(['signature', 'chain'])),
Future.filter(isValidSignatureResponse, 'error'),
Fetch.responseAsJson,
Future.encaseP(Fetch.fetchWithMethod(fetch, 'post', mpolluxSignUrl)),
R.assoc('content', R.prop('digest', content))
),
getSignatureOptions(fetch)
)
);

0 comments on commit 7edff45

Please sign in to comment.