Skip to content

Commit

Permalink
update hmac form and component to use 'algorithm' instead of 'hash-al…
Browse files Browse the repository at this point in the history
…gorithm' (#4604)
  • Loading branch information
madalynrose authored May 21, 2018
1 parent ca2bdbb commit 6888781
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
3 changes: 2 additions & 1 deletion ui/app/components/transit-key-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { get, set } = Ember;

const TRANSIT_PARAMS = {
hash_algorithm: 'sha2-256',
algorithm: 'sha2-256',
signature_algorithm: 'pss',
bits: 256,
bytes: 32,
Expand Down Expand Up @@ -31,7 +32,7 @@ const TRANSIT_PARAMS = {
const PARAMS_FOR_ACTION = {
sign: ['input', 'hash_algorithm', 'key_version', 'prehashed', 'signature_algorithm'],
verify: ['input', 'hmac', 'signature', 'hash_algorithm', 'prehashed'],
hmac: ['input', 'hash_algorithm', 'key_version'],
hmac: ['input', 'algorithm', 'key_version'],
encrypt: ['plaintext', 'context', 'nonce', 'key_version'],
decrypt: ['ciphertext', 'context', 'nonce'],
rewrap: ['ciphertext', 'context', 'nonce', 'key_version'],
Expand Down
12 changes: 6 additions & 6 deletions ui/app/templates/components/transit-key-action/hmac.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form {{action 'doSubmit' (hash input=input hash_algorithm=hash_algorithm key_version=key_version) on="submit"}}>
<form {{action 'doSubmit' (hash input=input algorithm=algorithm key_version=key_version) on="submit"}}>
{{#if hmac}}
<div class="box is-sideless is-fullwidth is-marginless">
<div class="field">
Expand Down Expand Up @@ -42,16 +42,16 @@
</div>
</div>
<div class="field">
<label for="hash_algorithm" class="is-label">Hash Algorithm</label>
<label for="algorithm" class="is-label">Hash Algorithm</label>
<div class="control is-expanded">
<div class="select is-fullwidth">
<select
name="hash_algorithm"
id="hash_algorithm"
onchange={{action (mut hash_algorithm) value="target.value"}}
name="algorithm"
id="algorithm"
onchange={{action (mut algorithm) value="target.value"}}
>
{{#each (sha2-digest-sizes) as |algo|}}
<option selected={{if hash_algorithm (eq hash_algorithm algo)}} value={{algo}}>
<option selected={{if algorithm (eq algorithm algo)}} value={{algo}}>
<code>{{algo}}</code>
</option>
{{/each}}
Expand Down
24 changes: 24 additions & 0 deletions ui/tests/integration/components/transit-key-actions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,27 @@ test('it can export a key: unwrapped, single version', function(assert) {
'passes expected args to the adapter'
);
});

test('it includes algorithm param for HMAC', function(assert) {
this.set('key', {
backend: 'transit',
id: 'akey',
supportedActions: ['hmac'],
validKeyVersions: [1],
});
this.render(hbs`{{transit-key-actions key=key}}`);
this.$('#algorithm').val('sha2-384').change();
this.$('button:submit').click();
assert.deepEqual(
this.get('storeService.callArgs'),
{
action: 'hmac',
backend: 'transit',
id: 'akey',
payload: {
algorithm: "sha2-384"
},
},
'passes expected args to the adapter'
);
});

0 comments on commit 6888781

Please sign in to comment.