Improvements from Codacy.

This commit is contained in:
Cyrille 2019-05-09 00:12:15 +01:00
parent a229f14017
commit c11aca651d
13 changed files with 28 additions and 28 deletions

View File

@ -46,7 +46,7 @@ The strategy is tested against the [greenlock-store-test](https://git.coolaj86.c
To run the tests yourself, create a `.env` file with the following
```
```console
// .env file
AWS_ACCESS_KEY_ID=abc // Replace with your accessKeyId
AWS_SECRET_ACCESS_KEY=abc // Replace with your secretAccessKey

View File

@ -5,15 +5,15 @@ require("dotenv").config();
let accessKeyId = process.env.AWS_ACCESS_KEY_ID
, secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY
, regionName = process.env.AWS_BUCKET_REGION
, bucketName = process.env.AWS_BUCKET_NAME
, bucketName = process.env.AWS_BUCKET_NAME;
var AWS = require("aws-sdk");
AWS.config.setPromisesDependency(Promise);
AWS.config.update({
region: regionName
, credentials: new AWS.Credentials({
accessKeyId: accessKeyId
, secretAccessKey: secretAccessKey
accessKeyId
, secretAccessKey
})
});

View File

@ -11,7 +11,7 @@ const defaultOptions = {
, bucketRegion: null
, accountsDir: "accounts/"
, configDir: "acme/"
}
};
const s3 = new AWS.S3({ apiVersion: "2006-03-01" });
@ -69,4 +69,4 @@ module.exports.create = (createOptions) => {
return handlers;
}
};

View File

@ -3,4 +3,4 @@ const fileNames = require("../fileNames");
module.exports.check = (opts, options, s3) => {
console.log("accounts.check", opts.account.id);
}
};

View File

@ -18,4 +18,4 @@ module.exports.checkKeypair = (opts, options, s3) => {
console.error("There was an error retrieving your account keypair:", err.message);
return null;
});
}
};

View File

@ -3,4 +3,4 @@ const fileNames = require("../fileNames");
module.exports.set = (opts, options, s3) => {
console.log("accounts.set");
}
};

View File

@ -5,7 +5,7 @@ module.exports.setKeypair = (opts, options, s3) => {
console.log("accounts.setKeypair for", opts.account);
let id = opts.account.id || opts.email || "single-user";
let key = pathHelper.accountsPath(options, id)
let key = pathHelper.accountsPath(options, id);
var body = JSON.stringify({
privateKeyPem: opts.keypair.privateKeyPem // string PEM

View File

@ -36,7 +36,7 @@ module.exports.check = (opts, options, s3) => {
privkey: values[0]
, cert: values[1]
, chain: values[2]
}
};
}).catch((err) => {
console.error("There was an error checking the ceritifcates:", err.message);
return null;

View File

@ -6,8 +6,8 @@ module.exports.checkKeypair = (opts, options, s3) => {
let id = opts.certificate.kid || opts.certificate.id || opts.subject;
pemKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.pem);
jwkKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.jwk);
let pemKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.pem);
let jwkKeyPath = pathHelper.certificatesPath(options, id, fileNames.privkey.jwk);
return s3.getObject({ Key: pemKeyPath, Bucket: options.bucketName }).promise().then((data) => {
console.log("Successfully retrieved certificate PEM keypair.");
@ -18,4 +18,4 @@ module.exports.checkKeypair = (opts, options, s3) => {
console.error("There was an error retrieving your certificate PEM keypair:", err.message);
return null;
});
}
};

View File

@ -15,4 +15,4 @@ module.exports.setKeypair = (opts, options, s3) => {
console.error("There was an error setting your PEM privateKey:", err.message);
throw err;
});
}
};

View File

@ -1,10 +1,10 @@
module.exports = {
privkey: {
pem: 'privkey.pem'
, jwk: 'privkey.jwk'
pem: "privkey.pem"
, jwk: "privkey.jwk"
}
, cert: 'cert.pem'
, chain: 'chain.pem'
, fullchain: 'fullchain.pem'
, bundle: 'bundle.pem'
}
, cert: "cert.pem"
, chain: "chain.pem"
, fullchain: "fullchain.pem"
, bundle: "bundle.pem"
};

View File

@ -1,6 +1,6 @@
const path = require("path");
tameWild = (wild) => {
const tameWild = (wild) => {
return wild.replace(/\*/g, "_");
}

10
test.js
View File

@ -5,15 +5,15 @@ require("dotenv").config();
let accessKeyId = process.env.AWS_ACCESS_KEY_ID
, secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY
, regionName = process.env.AWS_BUCKET_REGION
, bucketName = process.env.AWS_BUCKET_NAME
, bucketName = process.env.AWS_BUCKET_NAME;
let tester = require("greenlock-store-test");
let store = require("./index").create({
accessKeyId: accessKeyId
, secretAccessKey: secretAccessKey
, regionName: regionName
, bucketName: bucketName
accessKeyId
, secretAccessKey
, regionName
, bucketName
, configDir: "acme/"
, accountsDir: "accounts/"
, debug: true