forked from hyperledger-archives/composer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Identity warn when bound participant not found (Issue 3011) (hyperled…
…ger-archives#3665) * Identity warn no bound participant Signed-off-by: awjh-ibm <[email protected]> * Adding e2e tests Signed-off-by: awjh-ibm <[email protected]>
- Loading branch information
Showing
29 changed files
with
1,164 additions
and
148 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 |
---|---|---|
|
@@ -36,4 +36,4 @@ | |
"author": "Hyperledger Composer", | ||
"license": "Apache-2.0", | ||
"dependencies": {} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -16,11 +16,14 @@ | |
|
||
const Client = require('composer-client'); | ||
const BusinessNetworkConnection = Client.BusinessNetworkConnection; | ||
const BusinessNetworkDefinition = require('composer-common').BusinessNetworkDefinition; | ||
const Factory = require('composer-common').Factory; | ||
const ParticipantRegistry = Client.ParticipantRegistry; | ||
const IdentityRegistry = Client.IdentityRegistry; | ||
const ModelManager = require('composer-common').ModelManager; | ||
const Serializer = require('composer-common').Serializer; | ||
const Common = require('composer-common'); | ||
const BusinessNetworkDefinition = Common.BusinessNetworkDefinition; | ||
const Factory = Common.Factory; | ||
const Resource = Common.Resource; | ||
const ModelManager = Common.ModelManager; | ||
const Serializer = Common.Serializer; | ||
|
||
const CmdUtil = require('../../lib/cmds/utils/cmdutils.js'); | ||
const List = require('../../lib/cmds/identity/listCommand.js'); | ||
|
@@ -69,15 +72,38 @@ describe('composer identity list CLI unit tests', () => { | |
certificate: '', | ||
participant: factory.newRelationship('org.hyperledger.composer.system', 'Participant', '[email protected]') | ||
}); | ||
mockIdentityRegistry.getAll.resolves([identity1, identity2]); | ||
const identity3 = factory.newResource('org.hyperledger.composer.system', 'Identity', 'bfb8c488c0cdec07d9beeef6d97c27a77965ed9a8e30b57e40ea1eb399d8a1bd'); | ||
Object.assign(identity3, { | ||
name: 'admin', | ||
issuer: 'ac3dbcbe135ba48b29f97665bb103f8260c38d3872473e584314392797c595f3', | ||
state: 'ACTIVATED', | ||
certificate: '', | ||
participant: factory.newRelationship('org.hyperledger.composer.system', 'NetworkAdmin', 'admin') | ||
}); | ||
|
||
const identity4 = factory.newResource('org.hyperledger.composer.system', 'Identity', 'd1fa10f09219c13aeecbbbc4823a391f769b64f17124f2c136a9c09d7fd3789f'); | ||
Object.assign(identity4, { | ||
name: 'bob', | ||
issuer: 'bfb8c488c0cdec07d9beeef6d97c27a77965ed9a8e30b57e40ea1eb399d8a1be', | ||
state: 'REVOKED', | ||
certificate: '', | ||
participant: factory.newRelationship('org.hyperledger.composer.system', 'Participant', '[email protected]') | ||
}); | ||
mockIdentityRegistry.getAll.resolves([identity1, identity2, identity3, identity4]); | ||
sandbox.spy(console, 'log'); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
it('should list all identities in the business network using the specified profile', () => { | ||
it('should list all identities in the business network using the specified profile marking those where the participant does not exist', () => { | ||
let mockParticpantRegistry = sinon.createStubInstance(ParticipantRegistry); | ||
let mockParticipant1 = sinon.createStubInstance(Resource); | ||
mockParticipant1.getFullyQualifiedIdentifier.returns('org.hyperledger.composer.system.Participant#[email protected]'); | ||
mockParticpantRegistry.getAll.returns([mockParticipant1]); | ||
mockBusinessNetworkConnection.getAllParticipantRegistries.returns(Promise.resolve([mockParticpantRegistry])); | ||
|
||
let argv = { | ||
card :'cardName', | ||
participantId: 'org.doge.Doge#DOGE_1', | ||
|
@@ -89,12 +115,20 @@ describe('composer identity list CLI unit tests', () => { | |
sinon.assert.calledOnce(mockBusinessNetworkConnection.connect); | ||
sinon.assert.calledWith(mockBusinessNetworkConnection.connect, 'cardName'); | ||
sinon.assert.calledOnce(mockIdentityRegistry.getAll); | ||
sinon.assert.calledOnce(mockBusinessNetworkConnection.getAllParticipantRegistries); | ||
sinon.assert.calledWith(console.log, sinon.match(/identityId:.*eac9f8ff4e0a0df8017a40313c12bdfb9597928526d651e620598d17c9c875ca/)); | ||
sinon.assert.calledWith(console.log, sinon.match(/identityId:.*3b6cf18fe92474b6bc720401d5fb9590a3e2e3b67b1aa64ba7d3db85e746a3ba/)); | ||
sinon.assert.calledWith(console.log, sinon.match(/identityId:.*bfb8c488c0cdec07d9beeef6d97c27a77965ed9a8e30b57e40ea1eb399d8a1bd/)); | ||
sinon.assert.calledWith(console.log, sinon.match(/identityId:.*d1fa10f09219c13aeecbbbc4823a391f769b64f17124f2c136a9c09d7fd3789f/)); | ||
sinon.assert.calledWith(console.log, sinon.match(/state:.*ISSUED/)); | ||
sinon.assert.calledWith(console.log, sinon.match(/state:.*BOUND PARTICIPANT NOT FOUND/)); | ||
sinon.assert.calledWith(console.log, sinon.match(/state:.*ACTIVATED/)); | ||
sinon.assert.calledWith(console.log, sinon.match(/state:.*REVOKED/)); | ||
}); | ||
}); | ||
|
||
it('should error if the identities cannot be listed', () => { | ||
mockBusinessNetworkConnection.getAllParticipantRegistries.returns(Promise.resolve([])); | ||
mockIdentityRegistry.getAll.rejects(new Error('such error')); | ||
|
||
let argv = { | ||
|
Binary file not shown.
Binary file not shown.
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
45 changes: 45 additions & 0 deletions
45
packages/composer-playground/e2e/component/identity-issued.ts
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,45 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { browser, element, by, protractor } from 'protractor'; | ||
import { ExpectedConditions } from 'protractor'; | ||
|
||
import { OperationsHelper } from '../utils/operations-helper'; | ||
import { Constants } from '../constants'; | ||
|
||
export class IdentityIssued { | ||
static waitToAppear() { | ||
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.issue-identity'))), Constants.shortWait); | ||
} | ||
|
||
static addToWallet(cardName) { | ||
return OperationsHelper.click(element(by.id('option-1'))) | ||
.then(() => { | ||
browser.wait(ExpectedConditions.visibilityOf(element(by.id('cardName'))), Constants.shortWait); | ||
if (cardName) { | ||
return element(by.id('cardName')).clear() | ||
.then(() => { | ||
return element(by.id('cardName')).sendKeys(cardName); | ||
}); | ||
} else { | ||
return; | ||
} | ||
}) | ||
.then(() => { | ||
return element(by.id('option-1')).element(by.css('.primary')); | ||
}) | ||
.then((button) => { | ||
return OperationsHelper.click(button); | ||
}); | ||
} | ||
} |
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,65 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { browser, element, by, protractor } from 'protractor'; | ||
import { ExpectedConditions } from 'protractor'; | ||
|
||
import { OperationsHelper } from '../utils/operations-helper'; | ||
import { dragDropFile } from '../utils/fileUtils'; | ||
import { Constants } from '../constants'; | ||
|
||
export class Identity { | ||
static waitToAppear() { | ||
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.identity-title'))), Constants.shortWait); | ||
} | ||
|
||
static getMyIds() { | ||
return OperationsHelper.retrieveMatchingElementsByCSSFromParentByID('myIDs', '.identity', 0) | ||
.then((values) => { | ||
let promises = []; | ||
|
||
for (let i = 0; i < values.length; i++) { | ||
promises.push(OperationsHelper.retrieveTextFromElement(values[i])); | ||
} | ||
|
||
return protractor.promise.all(promises).then((texts) => { | ||
let IDs = []; | ||
texts.forEach((text) => { | ||
text = text.split('\n'); | ||
IDs.push({id: text[0], status: text[1]}); | ||
}); | ||
return IDs; | ||
}); | ||
}); | ||
} | ||
|
||
static getAllIds() { | ||
return OperationsHelper.retrieveMatchingElementsByCSSFromParentByID('allIDs', '.identity', 0) | ||
.then((values) => { | ||
let promises = []; | ||
|
||
for (let i = 0; i < values.length; i++) { | ||
promises.push(OperationsHelper.retrieveTextFromElement(values[i])); | ||
} | ||
|
||
return protractor.promise.all(promises).then((texts) => { | ||
let IDs = []; | ||
texts.forEach((text) => { | ||
text = text.split('\n'); | ||
IDs.push({id: text[0], issued: text[1], status: text[2]}); | ||
}); | ||
return IDs; | ||
}); | ||
}); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
packages/composer-playground/e2e/component/issue-identity.ts
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,60 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { browser, element, by, protractor } from 'protractor'; | ||
import { ExpectedConditions } from 'protractor'; | ||
|
||
import { OperationsHelper } from '../utils/operations-helper'; | ||
import { Constants } from '../constants'; | ||
|
||
export class IssueIdentity { | ||
static waitToAppear() { | ||
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.issue-identity'))), Constants.shortWait); | ||
} | ||
|
||
static inputUserId(userId) { | ||
return element(by.id('userID')).sendKeys(userId); | ||
} | ||
|
||
static inputParticipant(participant) { | ||
return element(by.id('participantFQI')).sendKeys(participant); | ||
} | ||
|
||
static selectParticipantType(identifiedBy, type) { | ||
return OperationsHelper.retrieveMatchingElementsByCSSFromParentByID('ngb-typeahead-0', '.dropdown-item', 0) | ||
.then((items) => { | ||
let promises = []; | ||
|
||
for (let i = 0; i < items.length; i++) { | ||
promises.push(OperationsHelper.retrieveTextFromElement(items[i])); | ||
} | ||
|
||
return protractor.promise.all(promises).then((texts) => { | ||
let id = -1; | ||
texts.forEach((text, index) => { | ||
text = text.split(' '); | ||
if (text[0] === identifiedBy && text[1] === type) { | ||
id = index; | ||
} | ||
}); | ||
if (id === -1) { | ||
throw new Error('Particpant not found: ' + identifiedBy + ', ' + type); | ||
} | ||
return items[id]; | ||
}); | ||
}) | ||
.then((el) => { | ||
return OperationsHelper.click(el); | ||
}) | ||
} | ||
} |
Oops, something went wrong.