|
@@ -13,17 +13,14 @@ describe('AccessTokenEncryptor', function () {
|
|
|
'2016.1:76a7d64a444ccee1a515b49c44844a69:m5YSkexUsLjcF4gLncm72+k='
|
|
'2016.1:76a7d64a444ccee1a515b49c44844a69:m5YSkexUsLjcF4gLncm72+k='
|
|
|
this.encrypted2019 =
|
|
this.encrypted2019 =
|
|
|
'2019.1:627143b2ab185a020c8720253a4c984e:7gnY6Ez3/Y3UWgLHLfBtJsE=:bf75cecb6aeea55b3c060e1122d2a82d'
|
|
'2019.1:627143b2ab185a020c8720253a4c984e:7gnY6Ez3/Y3UWgLHLfBtJsE=:bf75cecb6aeea55b3c060e1122d2a82d'
|
|
|
- this.encrypted2019v2 =
|
|
|
|
|
- '2019.1-v2:627143b2ab185a020c8720253a4c984e:7gnY6Ez3/Y3UWgLHLfBtJsE=:bf75cecb6aeea55b3c060e1122d2a82d'
|
|
|
|
|
this.encrypted2023 =
|
|
this.encrypted2023 =
|
|
|
'2023.1-v3:a6dd3781dd6ce93a4134874b505a209c:9TdIDAc8V9SeR0ffSn63Jj4=:d8b2de0b733c81b949993dce229abb4c'
|
|
'2023.1-v3:a6dd3781dd6ce93a4134874b505a209c:9TdIDAc8V9SeR0ffSn63Jj4=:d8b2de0b733c81b949993dce229abb4c'
|
|
|
this.badLabel = 'xxxxxx:c7a39310056b694c:jQf+Uh5Den3JREtvc82GW5Q='
|
|
this.badLabel = 'xxxxxx:c7a39310056b694c:jQf+Uh5Den3JREtvc82GW5Q='
|
|
|
this.badKey = '2015.1:d7a39310056b694c:jQf+Uh5Den3JREtvc82GW5Q='
|
|
this.badKey = '2015.1:d7a39310056b694c:jQf+Uh5Den3JREtvc82GW5Q='
|
|
|
this.badCipherText = '2015.1:c7a39310056b694c:xQf+Uh5Den3JREtvc82GW5Q='
|
|
this.badCipherText = '2015.1:c7a39310056b694c:xQf+Uh5Den3JREtvc82GW5Q='
|
|
|
this.settings = {
|
|
this.settings = {
|
|
|
- cipherLabel: '2019.1',
|
|
|
|
|
|
|
+ cipherLabel: '2023.1-v3',
|
|
|
cipherPasswords: {
|
|
cipherPasswords: {
|
|
|
- '2019.1-v2': '33333333333333333333333333333333333333',
|
|
|
|
|
'2023.1-v3': '44444444444444444444444444444444444444',
|
|
'2023.1-v3': '44444444444444444444444444444444444444',
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
@@ -130,7 +127,7 @@ describe('AccessTokenEncryptor', function () {
|
|
|
this.encryptor.encryptJson(this.testObject, (err, encrypted) => {
|
|
this.encryptor.encryptJson(this.testObject, (err, encrypted) => {
|
|
|
expect(err).to.be.null
|
|
expect(err).to.be.null
|
|
|
encrypted.should.match(
|
|
encrypted.should.match(
|
|
|
- /^2019.1:[0-9a-f]{32}:[a-zA-Z0-9=+/]+:[0-9a-f]{32}$/
|
|
|
|
|
|
|
+ /^2023.1-v3:[0-9a-f]{32}:[a-zA-Z0-9=+/]+:[0-9a-f]{32}$/
|
|
|
)
|
|
)
|
|
|
done()
|
|
done()
|
|
|
})
|
|
})
|
|
@@ -146,34 +143,6 @@ describe('AccessTokenEncryptor', function () {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
- describe('v3', function () {
|
|
|
|
|
- beforeEach(function () {
|
|
|
|
|
- this.settings.cipherLabel = '2023.1-v3'
|
|
|
|
|
- this.encryptor = new this.AccessTokenEncryptor(this.settings)
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- it('should encrypt the object', function (done) {
|
|
|
|
|
- this.encryptor.encryptJson(this.testObject, (err, encrypted) => {
|
|
|
|
|
- expect(err).to.be.null
|
|
|
|
|
- encrypted.should.match(
|
|
|
|
|
- /^2023.1-v3:[0-9a-f]{32}:[a-zA-Z0-9=+/]+:[0-9a-f]{32}$/
|
|
|
|
|
- )
|
|
|
|
|
- done()
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- it('should encrypt the object differently the next time', function (done) {
|
|
|
|
|
- this.encryptor.encryptJson(this.testObject, (err, encrypted1) => {
|
|
|
|
|
- expect(err).to.be.null
|
|
|
|
|
- this.encryptor.encryptJson(this.testObject, (err, encrypted2) => {
|
|
|
|
|
- expect(err).to.be.null
|
|
|
|
|
- encrypted1.should.not.equal(encrypted2)
|
|
|
|
|
- done()
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('decrypt', function () {
|
|
describe('decrypt', function () {
|
|
@@ -210,18 +179,13 @@ describe('AccessTokenEncryptor', function () {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it('should decrypt an 2019 string to get the same object', function (done) {
|
|
|
|
|
|
|
+ it('should not be able to decrypt a 2019 string', function (done) {
|
|
|
this.encryptor.decryptToJson(this.encrypted2019, (err, decrypted) => {
|
|
this.encryptor.decryptToJson(this.encrypted2019, (err, decrypted) => {
|
|
|
- expect(err).to.be.null
|
|
|
|
|
- expect(decrypted).to.deep.equal(this.testObject)
|
|
|
|
|
- done()
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- it('should decrypt an 2019 string with version to get the same object', function (done) {
|
|
|
|
|
- this.encryptor.decryptToJson(this.encrypted2019v2, (err, decrypted) => {
|
|
|
|
|
- expect(err).to.be.null
|
|
|
|
|
- expect(decrypted).to.deep.equal(this.testObject)
|
|
|
|
|
|
|
+ expect(err).to.exist
|
|
|
|
|
+ expect(err.message).to.equal(
|
|
|
|
|
+ 'unknown access-token-encryptor label 2019.1'
|
|
|
|
|
+ )
|
|
|
|
|
+ expect(decrypted).to.not.exist
|
|
|
done()
|
|
done()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|