it('bob should be able to read own data only', () => {
return useIdentity(bobCardName) .then(() => { // use a query, bob should only see his own data return businessNetworkConnection.query('selectMembers') .then((results) => { // check results results.length.should.equal(1); results[0].getIdentifier().should.equal('bob@email.com'); }); }); });
it('alice should be able to read own data only', () => {
return useIdentity(aliceCardName) .then(() => { // use a query, alice should only see her own data return businessNetworkConnection.query('selectMembers') .then((results) => { // check results results.length.should.equal(1); results[0].getIdentifier().should.equal('alice@email.com'); }); }); });
it('bob should be able to read alice data IFF granted access', () => {
return useIdentity(aliceCardName) .then(() => {
// alice grants access to her data to bob const authorize = factory.newTransaction('org.acme.pii', 'AuthorizeAccess'); authorize.memberId = 'bob@email.com'; return businessNetworkConnection.submitTransaction(authorize); }) .then(() => { return useIdentity(bobCardName); }) .then(() => {
// use a query, bob should be able to see his own and alice's data return businessNetworkConnection.query('selectMembers') .then((results) => { // check results results.length.should.equal(2); }); }) .then(() => { // switch back to alice return useIdentity(aliceCardName); }) .then(() => {
// alice revokes access to her data to bob const revoke = factory.newTransaction('org.acme.pii', 'RevokeAccess'); revoke.memberId = 'bob@email.com'; return businessNetworkConnection.submitTransaction(revoke); }) .then(() => { return useIdentity(bobCardName); }) .then(() => {
// use a query, bob should now only see his own data return businessNetworkConnection.query('selectMembers') .then((results) => { // check results results.length.should.equal(1); }); }); });
This network tracks the Lifecycle of Vehicles from manufacture to being scrapped involving private owners, manufacturers and scrap merchants. A regulator is able to provide oversight throughout this whole process.
Participants AuctionHouse Company Manufacturer PrivateOwner Regulator ScrapMerchant
describe('#placeOrder', function() { it('should be able to place an order for a vehicle', function() { return placeOrder() .then(function() { return businessNetworkConnection.getAssetRegistry(NS_M + '.Order'); }) .then(function(orderRegistry) { return orderRegistry.get(orderId); }) .then(function(order) { order.orderStatus.should.equal('PLACED'); }); }); });
it('should assign an owner to a vehicle and make it active', function() { const updateOrderStatus = factory.newTransaction(NS_M, 'UpdateOrderStatus'); updateOrderStatus.orderStatus = 'OWNER_ASSIGNED'; updateOrderStatus.vin = 'VIN_NUMBER'; updateOrderStatus.numberPlate = 'NUMBER_PLATE'; updateOrderStatus.v5c = 'V5C';
}); describe('#privateVehicleTransfer', function() { it('should be able to transfer a vehicle between two private owners', function() { const vehicleToTransfer = '123456789'; const owners = ['dan', 'simon'];
let vehicleRegistry; let privateOwnerRegistry; let vehicle;