2019-06-20 00:20:09 +02:00
|
|
|
import { assert } from 'chai'
|
2019-02-18 15:38:49 +01:00
|
|
|
|
2019-06-20 00:20:09 +02:00
|
|
|
import { config } from '../config'
|
2019-02-18 15:38:49 +01:00
|
|
|
|
2019-06-20 00:20:09 +02:00
|
|
|
import { Ocean, Account, DID } from '../../src' // @oceanprotocol/squid
|
2019-02-18 15:38:49 +01:00
|
|
|
|
2019-06-20 00:20:09 +02:00
|
|
|
describe('Secret Store', () => {
|
2019-02-18 15:38:49 +01:00
|
|
|
let ocean: Ocean
|
|
|
|
|
|
|
|
let account: Account
|
|
|
|
|
|
|
|
const did: DID = DID.generate()
|
2019-06-20 00:20:09 +02:00
|
|
|
const content = { content: 'Test 123' }
|
2019-02-18 15:38:49 +01:00
|
|
|
let encryptedContent
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
ocean = await Ocean.getInstance(config)
|
|
|
|
|
|
|
|
// Accounts
|
2019-06-24 13:06:38 +02:00
|
|
|
;[account] = await ocean.accounts.list()
|
2019-02-18 15:38:49 +01:00
|
|
|
})
|
|
|
|
|
2019-06-20 00:20:09 +02:00
|
|
|
it('should encrypt a text', async () => {
|
|
|
|
encryptedContent = await ocean.secretStore.encrypt(
|
|
|
|
did.getId(),
|
|
|
|
content,
|
|
|
|
account
|
|
|
|
)
|
2019-02-18 15:38:49 +01:00
|
|
|
|
|
|
|
assert.isDefined(encryptedContent)
|
2019-04-01 12:40:45 +02:00
|
|
|
assert.match(encryptedContent, /^0x[a-f0-9]{76}$/i)
|
2019-02-18 15:38:49 +01:00
|
|
|
})
|
|
|
|
})
|