Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More test coverage #92

Merged
merged 4 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/app/apping.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {strict as assert} from "assert";
import {randomPasscode, randomNonce} from '../../src/keri/app/apping'
import libsodium from "libsodium-wrappers-sumo"

describe('Controller', () => {
it('Random passcode', async () => {
await libsodium.ready;
let passcode = randomPasscode()
assert.equal(passcode.length, 22)
})

it('Random nonce', async () => {
await libsodium.ready;
let nonce = randomNonce()
assert.equal(nonce.length, 44)
})



})
65 changes: 65 additions & 0 deletions test/app/signify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,20 @@ describe('SignifyClient', () => {
assert.deepEqual(lastBody.ixn,{"v":"KERI10JSON000138_","t":"ixn","d":"EPtNJLDft3CB-oz3qIhe86fnTKs-GYWiWyx8fJv3VO5e","i":"ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK","s":"1","p":"ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK","a":[{"i":"ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK","s":0,"d":"ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK"}]})
assert.deepEqual(lastBody.sigs,["AADEzKk-5LT6vH-PWFb_1i1A8FW-KGHORtTOCZrKF4gtWkCr9vN1z_mDSVKRc6MKktpdeB3Ub1fWCGpnS50hRgoJ"])

await client.identifiers().addEndRole('aid1','agent')
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
lastBody = JSON.parse(lastCall[1]!.body!.toString())
assert.equal(lastCall[0]!,url+'/identifiers/aid1/endroles')
assert.equal(lastCall[1]!.method,'POST')
assert.equal(lastBody.rpy.t,'rpy')
assert.equal(lastBody.rpy.r,'/end/role/add')
assert.deepEqual(lastBody.rpy.a,{"cid":"ELUvZ8aJEHAQE-0nsevyYTP98rBbGJUrTj5an-pCmwrK","role":"agent"})

await client.identifiers().members('aid1')
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
assert.equal(lastCall[0]!,url+'/identifiers/aid1/members')
assert.equal(lastCall[1]!.method,'GET')

})

it('Randy identifiers', async () => {
Expand Down Expand Up @@ -385,6 +399,57 @@ describe('SignifyClient', () => {
assert.equal(lastCall[0]!,url+'/schema/'+schemaSAID)
assert.equal(lastCall[1]!.method,'GET')

})

it('OOBIs', async () => {
await libsodium.ready;
const bran = "0123456789abcdefghijk"

let client = new SignifyClient(url, bran, Tier.low, boot_url)

await client.boot()
await client.connect()

let oobis = client.oobis()

await oobis.get("aid","agent")
let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
assert.equal(lastCall[0]!,url+'/identifiers/aid/oobis?role=agent')
assert.equal(lastCall[1]!.method,'GET')

await oobis.resolve("http://oobiurl.com")
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
let lastBody = JSON.parse(lastCall[1]!.body!.toString())
assert.equal(lastCall[0]!,url+'/oobis')
assert.equal(lastCall[1]!.method,'POST')
assert.deepEqual(lastBody.url,"http://oobiurl.com")

await oobis.resolve("http://oobiurl.com","witness")
lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
lastBody = JSON.parse(lastCall[1]!.body!.toString())
assert.equal(lastCall[0]!,url+'/oobis')
assert.equal(lastCall[1]!.method,'POST')
assert.deepEqual(lastBody.url,"http://oobiurl.com")
assert.deepEqual(lastBody.oobialias,"witness")

})

it('Operations', async () => {
await libsodium.ready;
const bran = "0123456789abcdefghijk"

let client = new SignifyClient(url, bran, Tier.low, boot_url)

await client.boot()
await client.connect()

let ops = client.operations()

await ops.get("operationName")
let lastCall = fetchMock.mock.calls[fetchMock.mock.calls.length-1]!
assert.equal(lastCall[0]!,url+'/operations/operationName')
assert.equal(lastCall[1]!.method,'GET')


})

Expand Down
Loading