Skip to content

Commit

Permalink
'master'->JEN-178_152
Browse files Browse the repository at this point in the history
  • Loading branch information
zmicer committed Sep 27, 2016
2 parents cd1564a + a54b92d commit df918ad
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/main/java/hudson/plugins/blazemeter/BlazeMeterBuild.java
Expand Up @@ -40,6 +40,8 @@
import java.util.logging.FileHandler;
import java.util.logging.Logger;

import static hudson.plugins.blazemeter.utils.Constants.ENCRYPT_CHARS_NUM;


public class BlazeMeterBuild implements Callable<Result, Exception> {
private String jobApiKey = "";
Expand Down Expand Up @@ -99,7 +101,7 @@ public Result call() throws Exception {
api.setBzmLog(bzmLog);

String userEmail = JobUtility.getUserEmail(this.jobApiKey, this.serverUrl);
String apiKeyTrimmed = this.jobApiKey.substring(0, 4)+"...";
String apiKeyTrimmed = this.jobApiKey.substring(0, ENCRYPT_CHARS_NUM)+"...";
if (userEmail.isEmpty()) {
ProxyConfiguration proxy = ProxyConfiguration.load();
lentry.append("Please, check that settings are valid.");
Expand Down Expand Up @@ -129,7 +131,7 @@ public Result call() throws Exception {

String proxyPass = proxy.getPassword();

lentry.append("ProxyPass = " + (StringUtils.isBlank(proxyPass) ? "" : proxyPass.substring(0, 3)) + "...");
lentry.append("ProxyPass = " + (StringUtils.isBlank(proxyPass) ? "" : proxyPass.substring(0, ENCRYPT_CHARS_NUM)) + "...");
bzmLog.info(lentry.toString());
consLog.info(lentry.toString());
lentry.setLength(0);
Expand Down
Expand Up @@ -77,9 +77,9 @@ public ListBoxModel doFillTestIdItems(@QueryParameter("jobApiKey") String apiKey
try {
LinkedHashMultimap<String, String> testList = api.getTestsMultiMap();
if (testList == null){
items.add("Invalid API key ", "-1");
items.add(Constants.API_KEY_IS_NOT_VALID, "-1");
} else if (testList.isEmpty()){
items.add("No tests", "-1");
items.add(Constants.NO_TESTS_FOR_API_KEY, "-1");
} else {
Set set = testList.entries();
for (Object test : set) {
Expand Down
Expand Up @@ -92,7 +92,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
try {
boolean valid = DESCRIPTOR.validateCredentials(this.jobApiKey, CredentialsScope.GLOBAL);
if (!valid) {
listener.error("Can not start build: userKey=" + this.jobApiKey + " is absent in credentials store.");
listener.error("Can not start build: userKey=" + this.jobApiKey.substring(0,3) + "... is absent in credentials store.");
r=Result.NOT_BUILT;
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/blazemeter/api/TestType.java
Expand Up @@ -16,5 +16,5 @@


public enum TestType {
http, followme, multi, jmeter, webdriver, taurus
http, followme, multi, jmeter, webdriver, taurus, external
}
3 changes: 3 additions & 0 deletions src/main/java/hudson/plugins/blazemeter/utils/Constants.java
Expand Up @@ -28,4 +28,7 @@ public interface Constants {
String API_KEY_EMPTY ="API key is empty: please, enter valid API key";
String A_BLAZEMETER_COM="https://a.blazemeter.com";
String API_KEY_VALID="API key is valid: user e-mail=";
String API_KEY_IS_NOT_VALID="API key is not valid";
String NO_TESTS_FOR_API_KEY="No tests for api key";
int ENCRYPT_CHARS_NUM=3;
}
Expand Up @@ -40,6 +40,8 @@
import java.net.URLConnection;
import java.util.*;

import static hudson.plugins.blazemeter.utils.Constants.ENCRYPT_CHARS_NUM;


public class JobUtility {
private static StdErrLog logger = new StdErrLog(Constants.BZM_JEN);
Expand Down Expand Up @@ -530,7 +532,7 @@ public static FormValidation validateUserKey(String userKey, String blazeMeterUr
logger.warn(Constants.API_KEY_EMPTY);
return FormValidation.errorWithMarkup(Constants.API_KEY_EMPTY);
}
String encryptedKey = userKey.substring(0, 4) + "..." + userKey.substring(17);
String encryptedKey = userKey.substring(0, ENCRYPT_CHARS_NUM) + "...";
try {
logger.info("Validating API key started: API key=" + encryptedKey);
Api bzm = new ApiV3Impl(userKey, blazeMeterUrl);
Expand Down

0 comments on commit df918ad

Please sign in to comment.