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

test fix #1781

Merged
merged 1 commit into from Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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");
}
}
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
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
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
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