-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(): byok revoked error handling (#3083)
- Loading branch information
1 parent
d66a330
commit 9893f02
Showing
4 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const KMS_KEY_REVOKE_FAILURE = 'event:kms:key:revoke:encryption:failure'; | ||
export const KMS_KEY_REVOKE_ERROR_STATUS = 405; | ||
export const KMS_KEY_REVOKE_ERROR_CODES = [405005, 405006]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
packages/@webex/internal-plugin-encryption/test/unit/spec/kms-errors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import {assert} from '@webex/test-helper-chai'; | ||
import {handleKmsKeyRevokedEncryptionFailure} from '../../../src/kms-errors' | ||
import sinon from 'sinon'; | ||
|
||
describe('handleKmsKeyRevokedEncryptionFailure', () => { | ||
|
||
it('triggers `event:kms:key:revoke:encryption:failure` event when correct error code is detected', () => { | ||
const webex = { | ||
internal: { | ||
encryption: { | ||
trigger: sinon.spy() | ||
}, | ||
}, | ||
} | ||
|
||
const item = { | ||
status: 405, | ||
body: { | ||
errorCode: 405005, | ||
} | ||
} | ||
|
||
handleKmsKeyRevokedEncryptionFailure(item, webex); | ||
|
||
assert.calledOnce(webex.internal.encryption.trigger); | ||
assert.calledWithExactly(webex.internal.encryption.trigger, `event:kms:key:revoke:encryption:failure`); | ||
}); | ||
|
||
it('does not trigger `event:kms:key:revoke:encryption:failure` event when correct status but wrong error code is detected', () => { | ||
const webex = { | ||
internal: { | ||
encryption: { | ||
trigger: sinon.spy() | ||
}, | ||
}, | ||
} | ||
|
||
const item = { | ||
status: 405, | ||
body: { | ||
errorCode: 405009, | ||
} | ||
} | ||
|
||
handleKmsKeyRevokedEncryptionFailure(item, webex); | ||
|
||
assert.notCalled(webex.internal.encryption.trigger); | ||
}); | ||
|
||
it('does not trigger `event:kms:key:revoke:encryption:failure` event when wrong status but correct error code is detected', () => { | ||
const webex = { | ||
internal: { | ||
encryption: { | ||
trigger: sinon.spy() | ||
}, | ||
}, | ||
} | ||
|
||
const item = { | ||
status: 403, | ||
body: { | ||
errorCode: 405005, | ||
} | ||
} | ||
|
||
handleKmsKeyRevokedEncryptionFailure(item, webex); | ||
|
||
assert.notCalled(webex.internal.encryption.trigger); | ||
}); | ||
}); |