Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangayqian authored and hit-lacus committed Dec 23, 2021
1 parent 72c7665 commit f4daf14
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3403,4 +3403,8 @@ public String getKerberosJaasConfPath() {
public String getKerberosPrincipal() {
return getOptional("kylin.kerberos.principal");
}

public String getEncryptCipherIvSpec() {
return getOptional("kylin.security.encrypt.cipher.ivSpec", "AAAAAAAAAAAAAAAA");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.security.NoSuchAlgorithmException;

import org.apache.commons.codec.binary.Base64;
import org.apache.kylin.common.KylinConfig;

import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
Expand All @@ -42,7 +43,7 @@ private static final Cipher getCipher(int cipherMode) throws InvalidAlgorithmPar
InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, UnsupportedEncodingException {
Cipher cipher = Cipher.getInstance("AES/CFB/PKCS5Padding");
final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
IvParameterSpec ivSpec = new IvParameterSpec("AAAAAAAAAAAAAAAA".getBytes("UTF-8"));
IvParameterSpec ivSpec = new IvParameterSpec(KylinConfig.getInstanceFromEnv().getEncryptCipherIvSpec().getBytes("UTF-8"));
cipher.init(cipherMode, secretKey, ivSpec);
return cipher;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,21 @@

package org.apache.kylin.common.util;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class EncryptUtilTest {
public class EncryptUtilTest extends LocalFileMetadataTestCase {
@Before
public void setUp() throws Exception {
this.createTestMetadata();
}

@After
public void after() throws Exception {
this.cleanupTestMetadata();
}

@Test
public void testAESEncrypt(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ public BadQueryHistory getProjectBadQueryHistory(String project) throws IOExcept

public String dumpProjectDiagnosisInfo(String project, File exportPath) throws IOException {
Message msg = MsgPicker.getMsg();
String projectName = ValidateUtil.convertStringToBeAlphanumericUnderscore(project);
ProjectInstance projectInstance =
ProjectManager.getInstance(KylinConfig.getInstanceFromEnv())
.getProject(ValidateUtil.convertStringToBeAlphanumericUnderscore(project));
.getProject(projectName);
if (null == projectInstance) {
throw new BadRequestException(
String.format(Locale.ROOT, msg.getDIAG_PROJECT_NOT_FOUND(), project));
String.format(Locale.ROOT, msg.getDIAG_PROJECT_NOT_FOUND(), projectName));
}
aclEvaluate.checkProjectOperationPermission(projectInstance);
String[] args = { project, exportPath.getAbsolutePath() };
String[] args = { projectName, exportPath.getAbsolutePath() };
runDiagnosisCLI(args);
return getDiagnosisPackageName(exportPath);
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</init-param>
<init-param>
<param-name>cors.supportsCredentials </param-name>
<param-value>true</param-value>
<param-value>false</param-value>
</init-param>
</filter>

Expand Down

0 comments on commit f4daf14

Please sign in to comment.