Skip to content

Commit

Permalink
Change secret enrollment secret (hyperledger-archives#2815)
Browse files Browse the repository at this point in the history
* move to using enrollmentSecret from secret

Signed-off-by: Matthew B White <[email protected]>

* remove different versions of yargs in dependancies

Signed-off-by: Matthew B White <[email protected]>
  • Loading branch information
mbwhite authored and cazfletch committed Nov 22, 2017
1 parent 9bce1d3 commit 35e030e
Show file tree
Hide file tree
Showing 28 changed files with 72 additions and 72 deletions.
10 changes: 5 additions & 5 deletions packages/composer-admin/lib/adminconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class AdminConnection {
*
* @param {BusinessNetworkDefinition} businessNetworkDefinition usual network definition
* @param {Object[]} networkAdmins array of objects that are defining the network admins
* [ { name, certificate } , { name, secret }]
* [ { name, certificate } , { name, enrollmentSecret }]
* @return {Object[]} The bootstrap transactions.
* @private
*/
Expand Down Expand Up @@ -506,7 +506,7 @@ class AdminConnection {
certificate : networkAdmin.certificate
});
LOG.debug(method, 'Created bootstrap transaction to bind identity', identityTransaction);
} else if (networkAdmin.secret) {
} else if (networkAdmin.enrollmentSecret) {
// Handle an enrollment secret which requires an issue identity transaction.
identityTransaction = factory.newTransaction('org.hyperledger.composer.system', 'IssueIdentity');
Object.assign(identityTransaction, {
Expand Down Expand Up @@ -549,7 +549,7 @@ class AdminConnection {
* });
* @param {BusinessNetworkDefinition} businessNetworkDefinition - The business network to start
* @param {Object} [startOptions] connector specific start options
* NetworkAdmins: [ { name, certificate } , { name, secret }]
* NetworkAdmins: [ { name, certificate } , { name, enrollmentSecret }]
*
* @return {Promise} A promise that will be fufilled when the business network has been
* deployed - with a MAP of cards key is name
Expand Down Expand Up @@ -582,8 +582,8 @@ class AdminConnection {
};

let newCard;
if (networkAdmin.secret){
metadata.enrollmentSecret = networkAdmin.secret;
if (networkAdmin.enrollmentSecret ){
metadata.enrollmentSecret = networkAdmin.enrollmentSecret ;
newCard = new IdCard(metadata,connectionProfile);
} else {
newCard = new IdCard(metadata,connectionProfile);
Expand Down
30 changes: 15 additions & 15 deletions packages/composer-admin/test/adminconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,22 +268,22 @@ describe('AdminConnection', () => {
return adminConnection.start(businessNetworkDefinition, {
networkAdmins : [{
userName : 'admin',
secret : 'adminpw'
enrollmentSecret : 'adminpw'
}]
})
.then(() => {
sinon.assert.calledOnce(adminConnection._buildStartTransaction);
sinon.assert.calledWith(adminConnection._buildStartTransaction, businessNetworkDefinition, {
networkAdmins : [{
userName : 'admin',
secret : 'adminpw'
enrollmentSecret : 'adminpw'
}]
});
sinon.assert.calledOnce(mockConnection.start);
sinon.assert.calledWith(mockConnection.start, mockSecurityContext, 'name', '{"start":"json"}', {
networkAdmins : [{
userName : 'admin',
secret : 'adminpw'
enrollmentSecret : 'adminpw'
}]
});
});
Expand All @@ -297,22 +297,22 @@ describe('AdminConnection', () => {
return adminConnection.start(businessNetworkDefinition, {
networkAdmins : [{
userName : 'admin',
secret : 'adminpw'
enrollmentSecret : 'adminpw'
}, {userName : 'admin', certificate : 'cert'}]
})
.then(() => {
sinon.assert.calledOnce(adminConnection._buildStartTransaction);
sinon.assert.calledWith(adminConnection._buildStartTransaction, businessNetworkDefinition, {
networkAdmins : [{
userName : 'admin',
secret : 'adminpw'
enrollmentSecret : 'adminpw'
}, {userName : 'admin', certificate : 'cert'}]
});
sinon.assert.calledOnce(mockConnection.start);
sinon.assert.calledWith(mockConnection.start, mockSecurityContext, 'name', '{"start":"json"}', {
networkAdmins : [{
userName : 'admin',
secret : 'adminpw'
enrollmentSecret : 'adminpw'
}, {userName : 'admin', certificate : 'cert'}]
});
});
Expand All @@ -325,18 +325,18 @@ describe('AdminConnection', () => {
sinon.stub(adminConnection, '_buildStartTransaction').resolves({start : 'json'});
return adminConnection.start(businessNetworkDefinition, {
opt : 1,
networkAdmins : [{userName : 'admin', secret : 'adminpw'}]
networkAdmins : [{userName : 'admin', enrollmentSecret : 'adminpw'}]
})
.then(() => {
sinon.assert.calledOnce(adminConnection._buildStartTransaction);
sinon.assert.calledWith(adminConnection._buildStartTransaction, businessNetworkDefinition, {
opt : 1,
networkAdmins : [{userName : 'admin', secret : 'adminpw'}]
networkAdmins : [{userName : 'admin', enrollmentSecret : 'adminpw'}]
});
sinon.assert.calledOnce(mockConnection.start);
sinon.assert.calledWith(mockConnection.start, mockSecurityContext, 'name', '{"start":"json"}', {
opt : 1,
networkAdmins : [{userName : 'admin', secret : 'adminpw'}]
networkAdmins : [{userName : 'admin', enrollmentSecret : 'adminpw'}]
});
});
});
Expand Down Expand Up @@ -675,7 +675,7 @@ describe('AdminConnection', () => {
return adminConnection._buildStartTransaction(businessNetworkDefinition, {
networkAdmins : [{
userName : 'admin',
secret : 'adminpw'
enrollmentSecret : 'adminpw'
}, {userName : 'adminc', certificate : 'certcertcert'}]
})
.then((startTransactionJSON) => {
Expand Down Expand Up @@ -732,7 +732,7 @@ describe('AdminConnection', () => {
it('should build the start transaction if empty bootstrap transactions specified', () => {
return adminConnection._buildStartTransaction(businessNetworkDefinition, {
bootstrapTransactions : [],
networkAdmins : [{userName : 'admin', secret : 'adminpw'}]
networkAdmins : [{userName : 'admin', enrollmentSecret : 'adminpw'}]
})
.then((startTransactionJSON) => {
startTransactionJSON.should.deep.equal({
Expand Down Expand Up @@ -778,7 +778,7 @@ describe('AdminConnection', () => {
const startOptions = {
logLevel : 'DEBUG',
card : userCard,
networkAdmins : [{userName : 'admin', secret : 'adminpw'}]
networkAdmins : [{userName : 'admin', enrollmentSecret : 'adminpw'}]
};
return adminConnection._buildStartTransaction(businessNetworkDefinition, startOptions)
.then((startTransactionJSON) => {
Expand Down Expand Up @@ -817,7 +817,7 @@ describe('AdminConnection', () => {
it('should build the start transaction ignoring additional unmodelled properties from the start options', () => {
const startOptions = {
notAModelledProp : 'lulz',
networkAdmins : [{userName : 'admin', secret : 'adminpw'}]
networkAdmins : [{userName : 'admin', enrollmentSecret : 'adminpw'}]
};
return adminConnection._buildStartTransaction(businessNetworkDefinition, startOptions)
.then((startTransactionJSON) => {
Expand Down Expand Up @@ -965,14 +965,14 @@ describe('AdminConnection', () => {

return adminConnection._buildStartTransaction(businessNetworkDefinition, {
bootstrapTransactions,
networkAdmins : [{userName : 'admin', secret : 'adminpw'}]
networkAdmins : [{userName : 'admin', enrollmentSecret : 'adminpw'}]
}).should.eventually.be.rejectedWith('You cannot specify both network administrators and bootstrap transactions');
});

it('should throw error if no userName specified', () => {
return adminConnection._buildStartTransaction(businessNetworkDefinition, {
networkAdmins : [{
secret : 'adminpw'
enrollmentSecret : 'adminpw'
}]
}).should.eventually.be.rejectedWith('A user name must be specified for all network administrators');
});
Expand Down
4 changes: 2 additions & 2 deletions packages/composer-cli/lib/cmds/network/lib/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class Start {
if (argv.networkAdmin.certificate){
admin.certificate = argv.networkAdmin.certificate;
} else if (argv.networkAdmin.secret){
admin.secret = argv.networkAdmin.secret;
admin.enrollmentSecret = argv.networkAdmin.secret;
} else {
throw new Error('Need to have certificate or secret');
}
Expand All @@ -200,7 +200,7 @@ class Start {
if (argv.networkAdminCertificateFile){
admin.certificate = argv.networkAdminCertificateFile;
} else if (argv.networkAdminSecret){
admin.secret = argv.networkAdminSecret;
admin.enrollmentSecret = argv.networkAdminSecret;
} else {
throw new Error('Need to have certificate or secret');
}
Expand Down
6 changes: 3 additions & 3 deletions packages/composer-cli/test/network/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('composer deploy network CLI unit tests', function () {
'identities': [{ role: { mspId: 'Org1MSP', name: 'member' } }],
'policy': { '1-of': [{ 'signed-by': 0 }] }
},
networkAdmins: [{ file: 'default', secret: 'true', userName: 'admin' }]
networkAdmins: [{ file: 'default', enrollmentSecret : 'true', userName: 'admin' }]
});
});
});
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('composer deploy network CLI unit tests', function () {

{
endorsementPolicyFile: '/path/to/some/file.json',
networkAdmins: [{ secret: 'secret-secret', userName: 'admin' }]
networkAdmins: [{ enrollmentSecret : 'secret-secret', userName: 'admin' }]

}
);
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('composer deploy network CLI unit tests', function () {
sinon.assert.calledWith(mockAdminConnection.start, businessNetworkDefinition,
{
logLevel: 'DEBUG',
networkAdmins: [{ secret: 'secret-secret', userName: 'admin' }]
networkAdmins: [{ enrollmentSecret : 'secret-secret', userName: 'admin' }]
});
});
});
Expand Down
14 changes: 7 additions & 7 deletions packages/composer-cli/test/network/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('composer start network CLI unit tests', function () {
sinon.assert.calledOnce(mockAdminConnection.start);
sinon.assert.calledWith(mockAdminConnection.start, businessNetworkDefinition,
{
endorsementPolicy: optionsObject.endorsementPolicy, networkAdmins: [{ secret: 'true', userName: 'admin' }]
endorsementPolicy: optionsObject.endorsementPolicy, networkAdmins: [{ enrollmentSecret : 'true', userName: 'admin' }]
});
});
});
Expand All @@ -137,7 +137,7 @@ describe('composer start network CLI unit tests', function () {
sinon.assert.calledWith(mockAdminConnection.connect, 'cardname');
sinon.assert.calledOnce(mockAdminConnection.start);
sinon.assert.calledWith(mockAdminConnection.start, businessNetworkDefinition,
{ endorsementPolicyFile: '/path/to/some/file.json', networkAdmins: [{ secret: 'true', userName: 'admin' }]
{ endorsementPolicyFile: '/path/to/some/file.json', networkAdmins: [{ enrollmentSecret : 'true', userName: 'admin' }]

});
});
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('composer start network CLI unit tests', function () {
sinon.assert.calledOnce(mockAdminConnection.start);
sinon.assert.calledWith(mockAdminConnection.start, businessNetworkDefinition,
{
endorsementPolicy: VALID_ENDORSEMENT_POLICY_STRING, networkAdmins: [{ secret: 'true', userName: 'admin' }]
endorsementPolicy: VALID_ENDORSEMENT_POLICY_STRING, networkAdmins: [{ enrollmentSecret : 'true', userName: 'admin' }]
});
});
});
Expand Down Expand Up @@ -196,7 +196,7 @@ describe('composer start network CLI unit tests', function () {
sinon.assert.calledWith(mockAdminConnection.connect, 'cardname');
sinon.assert.calledOnce(mockAdminConnection.start);
sinon.assert.calledWith(mockAdminConnection.start, businessNetworkDefinition,
{ networkAdmins: [{ secret: 'true', userName: 'admin' }]} );
{ networkAdmins: [{ enrollmentSecret : 'true', userName: 'admin' }]} );
});
});

Expand Down Expand Up @@ -248,7 +248,7 @@ describe('composer start network CLI unit tests', function () {
sinon.assert.calledWith(mockAdminConnection.connect, 'cardname');
sinon.assert.calledOnce(mockAdminConnection.start);
sinon.assert.calledWith(mockAdminConnection.start, businessNetworkDefinition,
{ networkAdmins: [{ file: 'mycardfile', secret: 'true', userName: 'admin' }] } );
{ networkAdmins: [{ file: 'mycardfile', enrollmentSecret : 'true', userName: 'admin' }] } );
} );
});

Expand All @@ -274,7 +274,7 @@ describe('composer start network CLI unit tests', function () {
sinon.assert.calledOnce(mockAdminConnection.connect);
sinon.assert.calledWith(mockAdminConnection.connect, 'cardname');
sinon.assert.calledOnce(mockAdminConnection.start);
sinon.assert.calledWith(mockAdminConnection.start, businessNetworkDefinition,{ networkAdmins: [{ secret: 'true', userName: 'admin' }],logLevel: 'DEBUG' });
sinon.assert.calledWith(mockAdminConnection.start, businessNetworkDefinition,{ networkAdmins: [{ enrollmentSecret : 'true', userName: 'admin' }],logLevel: 'DEBUG' });
});
});

Expand All @@ -300,7 +300,7 @@ describe('composer start network CLI unit tests', function () {
sinon.assert.calledWith(mockAdminConnection.connect,'cardname');
sinon.assert.calledOnce(mockAdminConnection.start);
sinon.assert.calledWith(mockAdminConnection.start, businessNetworkDefinition, {
networkAdmins: [{ secret: 'true', userName: 'admin' }]
networkAdmins: [{ enrollmentSecret : 'true', userName: 'admin' }]
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/composer-connector-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"serializerr": "1.0.3",
"socket.io": "1.7.3",
"uuid": "3.0.1",
"yargs": "8.0.1"
"yargs": "10.0.3"
},
"devDependencies": {
"chai": "3.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/composer-cucumber-steps/lib/composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class Composer {
return this.adminConnection.start(this.businessNetworkDefinition, {
networkAdmins : [{
userName : 'admin',
secret : 'adminpw'
enrollmentSecret : 'adminpw'
}]
});
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe('SampleBusinessNetworkService', () => {
let createdCardMap = new Map<string, IdCard>();
let createdCard = new IdCard({
userName: 'admin',
secret: 'adminpw',
enrollmentSecret: 'adminpw',
businessNetwork: 'myNetwork'
}, {name: 'myProfile', type: 'hlfv1'});
createdCardMap.set('admin', createdCard);
Expand All @@ -218,7 +218,7 @@ describe('SampleBusinessNetworkService', () => {
adminMock.start.should.have.been.calledWith(sinon.match.object, {
networkAdmins: [{
userName: 'admin',
secret: 'adminpw'
enrollmentSecret : 'adminpw'
}]
});
adminMock.importCard.should.have.been.calledWith('myCardName', createdCard);
Expand All @@ -230,7 +230,7 @@ describe('SampleBusinessNetworkService', () => {
let createdCardMap = new Map<string, IdCard>();
let createdCard = new IdCard({
userName: 'myUserId',
secret: 'adminpw',
enrollmentSecret: 'adminpw',
businessNetwork: 'myNetwork'
}, {name: 'myProfile', type: 'hlfv1'});
createdCardMap.set('myUserId', createdCard);
Expand All @@ -254,7 +254,7 @@ describe('SampleBusinessNetworkService', () => {
adminMock.start.should.have.been.calledWith(sinon.match.object, {
networkAdmins: [{
userName: 'myUserId',
secret: 'mySecret'
enrollmentSecret: 'mySecret'
}]
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export class SampleBusinessNetworkService {
if (credentials) {
networkAdmin['certificate'] = credentials.certificate;
} else if (networkSecret) {
networkAdmin['secret'] = networkSecret;
networkAdmin['enrollmentSecret'] = networkSecret;
} else {
networkAdmin['secret'] = 'adminpw';
networkAdmin['enrollmentSecret'] = 'adminpw';
}

cardName = cardName || networkId + '@' + networkName;
Expand Down
2 changes: 1 addition & 1 deletion packages/composer-rest-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"strong-error-handler": "1.0.1",
"touch": "1.0.0",
"ws": "3.0.0",
"yargs": "8.0.1"
"yargs": "10.0.3"
},
"devDependencies": {
"chai": "3.5.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/composer-rest-server/test/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const clone = require('clone');
before(() => {
const cardStore = new MemoryCardStore();
adminConnection = new AdminConnection({ cardStore });
let metadata = { version:1, userName: 'admin', secret: 'adminpw', roles: ['PeerAdmin', 'ChannelAdmin'] };
let metadata = { version:1, userName: 'admin', enrollmentSecret: 'adminpw', roles: ['PeerAdmin', 'ChannelAdmin'] };
const deployCardName = 'deployer-card';

let idCard_PeerAdmin = new IdCard(metadata, {type : 'embedded',name:'defaultProfile'});
Expand All @@ -152,7 +152,7 @@ const clone = require('clone');
return adminConnection.install(businessNetworkDefinition.getName());
})
.then(()=>{
return adminConnection.start(businessNetworkDefinition,{networkAdmins :[{userName:'admin',secret:'adminpw'}] });
return adminConnection.start(businessNetworkDefinition,{networkAdmins :[{userName:'admin',enrollmentSecret:'adminpw'}] });
})
.then(() => {
idCard = new IdCard({ userName: 'admin', enrollmentSecret: 'adminpw', businessNetwork: 'bond-network' }, { name: 'defaultProfile', type: 'embedded' });
Expand Down
Loading

0 comments on commit 35e030e

Please sign in to comment.