Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cloud Storage encryption samples and tests. #165

Merged
merged 3 commits into from
Aug 11, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions storage/encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function generateEncryptionKey () {
* @param {string} srcFileName The local file to be uploaded.
* @param {string} destFileName The name of the destination file.
* @param {string} key The encryption key.
* @param {function} key The callback function.
* @param {function} callback The callback function.
*/
function uploadEncryptedFile (bucketName, srcFileName, destFileName, key, callback) {
if (!bucketName) {
Expand Down Expand Up @@ -97,8 +97,8 @@ function uploadEncryptedFile (bucketName, srcFileName, destFileName, key, callba
* file.
*
* @param {string} bucketName The bucket from which the file will be downloaded.
* @param {string} srcFileName The local file to be downloaded.
* @param {string} destFileName The name of the destination file.
* @param {string} srcFileName The name of the file to be downloaded.
* @param {string} destFileName The local path to which to save the file.
* @param {string} key The encryption key.
* @param {function} key The callback function.
*/
Expand Down
6 changes: 6 additions & 0 deletions storage/system-test/encryption.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,27 @@ var downloadFilePath = path.join(__dirname, '../resources/downloaded.txt');

describe('storage:encryption', function () {
var key;

before(function (done) {
// Create an key to use throughout the test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar nit: create a key.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

key = program.generateEncryptionKey();
// Create a test bucket
storage.createBucket(bucketName, done);
});

after(function (done) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain what this does with a comment? (e.g. "Reset GCS bucket after running all tests" or something.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments

try {
// Delete the downloaded file
fs.unlinkSync(downloadFilePath);
} catch (err) {
console.log(err);
}
// Delete any files that were uploaded
storage.bucket(bucketName).deleteFiles({ force: true }, function (err) {
if (err) {
return done(err);
}
// Delete the test bucket
storage.bucket(bucketName).delete(done);
});
});
Expand Down
3 changes: 2 additions & 1 deletion storage/test/encryption.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('storage:encryption', function () {

describe('downloadEncryptedFile', function () {
var fileName = 'test.txt';
it('should upload a file', function () {
it('should download a file', function () {
var sample = getSample();

sample.program.downloadEncryptedFile(bucketName, fileName, fileName, 'key', function (err) {
Expand Down Expand Up @@ -181,6 +181,7 @@ describe('storage:encryption', function () {
});

describe('rotateEncryptionKey', function () {
it('should be implemented');
it('should rotate an encryption key', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to put an it ('should be implemented') here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

var sample = getSample();

Expand Down