2019-02-18 15:38:49 +01:00
|
|
|
import { assert } from "chai"
|
|
|
|
|
|
|
|
import { config } from "../config"
|
|
|
|
|
|
|
|
import { Ocean, Account, DID } from "../../src" // @oceanprotocol/squid
|
|
|
|
|
|
|
|
describe("Secret Store", () => {
|
|
|
|
let ocean: Ocean
|
|
|
|
|
|
|
|
let account: Account
|
|
|
|
|
|
|
|
const did: DID = DID.generate()
|
|
|
|
const content = {content: "Test 123"}
|
|
|
|
let encryptedContent
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
ocean = await Ocean.getInstance(config)
|
|
|
|
|
|
|
|
// Accounts
|
2019-04-01 12:40:45 +02:00
|
|
|
account = (await ocean.accounts.list())[0]
|
2019-02-18 15:38:49 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it("should encrypt a text", async () => {
|
|
|
|
encryptedContent = await ocean.secretStore.encrypt(did.getId(), content, account)
|
|
|
|
|
|
|
|
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
|
|
|
})
|
|
|
|
})
|