-
Notifications
You must be signed in to change notification settings - Fork 1
/
Metadata.test.ts
54 lines (49 loc) · 1.79 KB
/
Metadata.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { assert } from 'chai'
import { decodeJwt, JWTPayload } from 'jose'
import config from '../../test/config'
import { Nevermined } from '../../src/nevermined/Nevermined'
import { NvmAccount } from '../../src/models/NvmAccount'
import { getAssetPrice, getMetadata } from '../utils'
import { AssetPrice } from '../../src/models/AssetPrice'
import { AssetAttributes } from '../../src/models/AssetAttributes'
import { DID } from '../../src/nevermined/DID'
describe('Get DDO status', () => {
let nevermined: Nevermined
let publisher: NvmAccount
let assetPrice: AssetPrice
let payload: JWTPayload
before(async () => {
nevermined = await Nevermined.getInstance(config)
;[publisher] = nevermined.accounts.list()
assetPrice = getAssetPrice(publisher.getId())
const clientAssertion = await nevermined.utils.jwt.generateClientAssertion(publisher)
await nevermined.services.marketplace.login(clientAssertion)
payload = decodeJwt(config.marketplaceAuthToken)
})
it('should get the internal status of an asset', async () => {
const metadata = getMetadata()
metadata.userId = payload.sub
const ddo = await nevermined.assets.create(
AssetAttributes.getInstance({
metadata,
services: [
{
serviceType: 'access',
price: assetPrice,
},
],
}),
publisher,
)
const ddoStatus = await nevermined.services.metadata.status(ddo.id)
assert.isDefined(ddoStatus)
assert.isDefined(ddoStatus.internal)
assert.equal(ddoStatus.internal.id, ddo.id)
assert.equal(ddoStatus.internal.type, 'Elasticsearch')
assert.equal(ddoStatus.internal.status, 'ACCEPTED')
assert.equal(
ddoStatus.internal.url,
nevermined.services.metadata.getServiceEndpoint(DID.parse(ddo.id)),
)
})
})