Skip to content

Commit

Permalink
Expand Testing - Source Files
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-cronin committed Aug 24, 2020
1 parent fbb27a3 commit e03d951
Show file tree
Hide file tree
Showing 25 changed files with 1,517 additions and 333 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jest:
stage: check
image: node:12
script:
- npm run build:all
- npm run test

build_all:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"futoin-hkdf": "^1.3.2",
"google-auth-library": "^6.0.5",
"google-protobuf": "^4.0.0-rc.2",
"isomorphic-git": "^1.5.0",
"isomorphic-git": "^1.7.4",
"kbpgp": "^2.0.82",
"keybase-bot": "^3.6.1",
"node-forge": "^0.9.1",
Expand Down
3 changes: 1 addition & 2 deletions proto/Agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ message SignFileResponseMessage {
// ==== VerifyFile ==== //
message VerifyFileRequestMessage {
string file_path = 1;
string signature_path = 2;
string public_key_path = 3;
string public_key_path = 2;
}
message VerifyFileResponseMessage {
bool verified = 1;
Expand Down
9 changes: 0 additions & 9 deletions src/cli/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function makeStartAgentCommand() {
const pid = await PolykeyAgent.startAgent(daemon);
pkLogger(`agent has started with pid of ${pid}`, PKMessageType.SUCCESS);
}
process.exit();
}),
);
}
Expand All @@ -36,7 +35,6 @@ function makeRestartAgentCommand() {
const daemon: boolean = options.daemon;
const pid = await PolykeyAgent.startAgent(daemon);
pkLogger(`agent has restarted with pid of ${pid}`, PKMessageType.SUCCESS);
process.exit();
}),
);
}
Expand All @@ -47,7 +45,6 @@ function makeAgentStatusCommand() {
const client = PolykeyAgent.connectToAgent();
const status = await client.getAgentStatus();
pkLogger(`agent status is: '${status}'`, PKMessageType.INFO);
process.exit();
}),
);
}
Expand Down Expand Up @@ -76,7 +73,6 @@ function makeStopAgentCommand() {
throw Error('agent failed to stop');
}
}
process.exit();
}),
);
}
Expand All @@ -98,7 +94,6 @@ function makeListNodesCommand() {
pkLogger(node, PKMessageType.INFO);
}
}
process.exit();
}),
);
}
Expand Down Expand Up @@ -127,8 +122,6 @@ function makeNewNodeCommand() {
} else {
throw Error('something went wrong with node creation');
}

process.exit();
}),
);
}
Expand All @@ -150,8 +143,6 @@ function makeLoadNodeCommand() {
} else {
throw Error('something went wrong when loading node');
}

process.exit();
}),
);
}
Expand Down
12 changes: 5 additions & 7 deletions src/cli/Crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ function makeVerifyCommand() {
'-k, --public-key <publicKey>',
'path to public key that will be used to verify files, defaults to primary key',
)
.option('-s, --detach-sig <detachSig>', 'path to detached signature for file, defaults to [filename].sig')
.requiredOption('-f, --verified-file <verifiedFile>', 'file to be verified')
.requiredOption('-f, --signed-file <signedFile>', 'file to be verified')
.action(
actionRunner(async (options) => {
const client = PolykeyAgent.connectToAgent();
Expand All @@ -60,9 +59,8 @@ function makeVerifyCommand() {
const nodePath = determineNodePath(options);
const publicKey = options.publicKey;
const filePath = options.signedFile;
const signaturePath = options.detachSig ?? filePath + '.sig';

const verified = await client.verifyFile(nodePath, filePath, signaturePath);
const verified = await client.verifyFile(nodePath, filePath, publicKey);
if (verified) {
pkLogger(`file '${filePath}' was successfully verified`, PKMessageType.SUCCESS);
} else {
Expand Down Expand Up @@ -91,7 +89,7 @@ function makeEncryptCommand() {
const nodePath = determineNodePath(options);

const publicKey = options.publicKey;
const filePath = options.filePath
const filePath = options.filePath;

try {
const encryptedPath = await client.encryptFile(nodePath, filePath, publicKey);
Expand Down Expand Up @@ -124,7 +122,7 @@ function makeDecryptCommand() {

const privateKey = options.privateKey;
const keyPassphrase = options.keyPassphrase;
const filePath = options.filePath
const filePath = options.filePath;

try {
const decryptedPath = await client.decryptFile(nodePath, filePath, privateKey, keyPassphrase);
Expand All @@ -142,7 +140,7 @@ function makeCryptoCommand() {
.addCommand(makeVerifyCommand())
.addCommand(makeSignCommand())
.addCommand(makeEncryptCommand())
.addCommand(makeDecryptCommand())
.addCommand(makeDecryptCommand());
}

export default makeCryptoCommand;
10 changes: 5 additions & 5 deletions src/cli/Keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function makeDeleteKeyCommand() {

const successful = await client.deleteKey(nodePath, keyName);
pkLogger(
`key '${keyName}' was ${successful ? '' : 'un-'}sucessfully deleted`,
`key '${keyName}' was ${successful ? '' : 'un-'}successfully deleted`,
successful ? PKMessageType.SUCCESS : PKMessageType.INFO,
);
}),
Expand Down Expand Up @@ -93,14 +93,14 @@ function makeListPrimaryKeyPairCommand() {
if (outputJson) {
pkLogger(JSON.stringify(keypair), PKMessageType.INFO);
} else {
pkLogger("Public Key:", PKMessageType.SUCCESS);
pkLogger('Public Key:', PKMessageType.SUCCESS);
pkLogger(keypair.publicKey, PKMessageType.INFO);
if (privateKey) {
pkLogger("Private Key:", PKMessageType.SUCCESS);
pkLogger('Private Key:', PKMessageType.SUCCESS);
pkLogger(keypair.privateKey, PKMessageType.INFO);
}
}
})
}),
);
}

Expand All @@ -111,7 +111,7 @@ function makeKeyManagerCommand() {
.addCommand(makeDeleteKeyCommand())
.addCommand(makeListKeysCommand())
.addCommand(makeGetKeyCommand())
.addCommand(makeListPrimaryKeyPairCommand())
.addCommand(makeListPrimaryKeyPairCommand());
}

export default makeKeyManagerCommand;
Loading

0 comments on commit e03d951

Please sign in to comment.