-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
584 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,70 @@ | ||
const faker = require('faker'); | ||
const { sendGetRequest, sendPostRequest, responseStatus: {OK}, assert } = require("../config"); | ||
const { getSession } = require("../libs/sessionLibrary"); | ||
const { testData } = require("../libs/bootstrap.js"); | ||
const { | ||
sendGetRequest, | ||
sendPostRequest, | ||
responseStatus: { OK }, | ||
assert, | ||
} = require('../config'); | ||
const { getSession } = require('../libs/sessionLibrary'); | ||
const { testData } = require('../libs/bootstrap.js'); | ||
|
||
let bearer = null; | ||
const {apiKey} = testData; | ||
const { apiKey } = testData; | ||
const wallet = testData.wallet.name; | ||
const {password} = testData.wallet; | ||
const { password } = testData.wallet; | ||
const limit = 50; | ||
const url = `/wallets?limit=${limit}`; | ||
|
||
describe("Wallets (Wallet API)", function () { | ||
before(async () => { | ||
bearer = await getSession(wallet, password); | ||
}); | ||
it('Wallets - Returns 200 response status @wallet @regression', async () => { | ||
const { token } = bearer; | ||
const headers = { | ||
'Authorization': `Bearer ${token}`, | ||
'treetracker-api-key': apiKey, | ||
}; | ||
const response = await sendGetRequest(url, headers); | ||
const { status } = response; | ||
assert.equals(status, OK, 'Response status does not equal!'); | ||
}); | ||
describe.only('Wallets (Wallet API)', function () { | ||
before(async () => { | ||
bearer = await getSession(wallet, password); | ||
}); | ||
it('Wallets - Returns 200 response status @wallet @regression', async () => { | ||
const { token } = bearer; | ||
const headers = { | ||
Authorization: `Bearer ${token}`, | ||
'treetracker-api-key': apiKey, | ||
}; | ||
const response = await sendGetRequest(url, headers); | ||
const { status } = response; | ||
assert.equals(status, OK, 'Response status does not equal!'); | ||
}); | ||
|
||
it('Wallets - Verify new managed wallet is created successfully @wallet @regression', async () => { | ||
const expectedWallet = `NewWalletByAutoTool_${faker.datatype.number()}`; | ||
let walletCreated = false; | ||
const { token } = bearer; | ||
const headers = { | ||
'Authorization': `Bearer ${token}`, | ||
'treetracker-api-key': apiKey | ||
}; | ||
const payload = { | ||
"wallet": expectedWallet | ||
}; | ||
const newWalletResponse = await sendPostRequest('/wallets', headers, payload); | ||
const {status} = newWalletResponse; | ||
assert.equals(status, OK, 'Response status does not match!'); | ||
it('Wallets - Verify new managed wallet is created successfully @wallet @regression', async () => { | ||
const expectedWallet = `NewWalletByAutoTool_${faker.datatype.number()}`; | ||
let walletCreated = false; | ||
const { token } = bearer; | ||
const headers = { | ||
Authorization: `Bearer ${token}`, | ||
'treetracker-api-key': apiKey, | ||
}; | ||
const payload = { | ||
wallet: expectedWallet, | ||
}; | ||
const newWalletResponse = await sendPostRequest( | ||
'/wallets', | ||
headers, | ||
payload, | ||
); | ||
const { status } = newWalletResponse; | ||
assert.equals(status, OK, 'Wallet could not be created'); | ||
|
||
const response = await sendGetRequest(url, headers); | ||
const { wallets } = response.body; | ||
assert.equals(response.status, OK, 'Response status does not match!'); | ||
const response = await sendGetRequest(url, headers); | ||
const { wallets } = response.body; | ||
assert.equals(response.status, OK, 'Created Wallet not found'); | ||
|
||
for (const wallet of wallets) { | ||
if (Object.values(wallet).includes(expectedWallet)) { | ||
walletCreated = true; | ||
break; | ||
} | ||
} | ||
for (const wallet of wallets) { | ||
if (Object.values(wallet).includes(expectedWallet)) { | ||
walletCreated = true; | ||
break; | ||
} | ||
} | ||
|
||
assert.equals(walletCreated, true, 'Wallet was not created!', response.body); | ||
}) | ||
}); | ||
assert.equals( | ||
walletCreated, | ||
true, | ||
'Wallet was not created!', | ||
response.body, | ||
); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const TrustRepository = require('../repositories/TrustRepository'); | ||
|
||
class Trust { | ||
constructor(session) { | ||
this.trustRepository = new TrustRepository(session); | ||
} | ||
|
||
/* | ||
* Get trust relationships by filters, setting filter to undefined to allow all data | ||
*/ | ||
async getTrustRelationships({ | ||
walletId, | ||
state, | ||
type, | ||
request_type, | ||
offset, | ||
limit, | ||
}) { | ||
const filter = { | ||
and: [ | ||
{ | ||
or: [ | ||
{ | ||
actor_wallet_id: walletId, | ||
}, | ||
{ | ||
target_wallet_id: walletId, | ||
}, | ||
{ | ||
originator_wallet_id: walletId, | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
if (state) { | ||
filter.and.push({ state }); | ||
} | ||
if (type) { | ||
filter.and.push({ type }); | ||
} | ||
if (request_type) { | ||
filter.and.push({ request_type }); | ||
} | ||
return this.trustRepository.getByFilter(filter, { offset, limit }); | ||
} | ||
} | ||
|
||
module.exports = Trust; |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.