-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix secure password generation and use.
- Loading branch information
Showing
8 changed files
with
145 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
src/test/java/com/cloudera/utils/hadoop/hms/EncryptValidationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* Copyright 2021 Cloudera, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.cloudera.utils.hadoop.hms; | ||
|
||
import com.cloudera.utils.hadoop.hms.mirror.MessageCode; | ||
import org.junit.After; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.assertFalse; | ||
|
||
public class EncryptValidationTest extends MirrorTestBase { | ||
@Before | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
DataState.getInstance().setConfiguration(CDP_ENCRYPT); | ||
if (DataState.getInstance().getPopulate() == null) { | ||
DataState.getInstance().setPopulate(Boolean.FALSE); | ||
} | ||
dataSetup01(); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
dataCleanup(Boolean.TRUE); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDownClass() throws Exception { | ||
dataCleanup(Boolean.FALSE); | ||
} | ||
|
||
@Test | ||
public void test_pkey_test() { | ||
String nameofCurrMethod = new Throwable() | ||
.getStackTrace()[0] | ||
.getMethodName(); | ||
|
||
String outputDir = outputDirBase + nameofCurrMethod; | ||
|
||
String[] args = new String[]{"-pkey", "test", | ||
"-p", "myspecialpassword"}; | ||
args = toExecute(args, execArgs, Boolean.FALSE); | ||
|
||
long rtn = 0; | ||
Mirror mirror = new Mirror(); | ||
rtn = mirror.go(args); | ||
long check = 0; | ||
// MessageCode.RESET_TO_DEFAULT_LOCATION_WITHOUT_WAREHOUSE_DIRS.getLong(); | ||
|
||
assertTrue("Return Code Failure: " + rtn + " doesn't match: " + check, rtn == check); | ||
} | ||
|
||
@Test | ||
public void test_p_test() { | ||
String nameofCurrMethod = new Throwable() | ||
.getStackTrace()[0] | ||
.getMethodName(); | ||
|
||
String outputDir = outputDirBase + nameofCurrMethod; | ||
|
||
String[] args = new String[]{ | ||
"-pkey", "test1", | ||
"-db", DataState.getInstance().getWorking_db(), | ||
"-o", outputDir, "-cfg", DataState.getInstance().getConfiguration()}; | ||
args = toExecute(args, execArgs, Boolean.FALSE); | ||
|
||
long rtn = 0; | ||
Mirror mirror = new Mirror(); | ||
rtn = mirror.go(args); | ||
long check = MessageCode.PASSWORD_DECRYPT_ISSUE.getLong(); | ||
|
||
assertTrue("Return Code Failure: " + rtn + " doesn't match: " + check, rtn == check); | ||
} | ||
|
||
@Test | ||
public void test_p_test_02() { | ||
String nameofCurrMethod = new Throwable() | ||
.getStackTrace()[0] | ||
.getMethodName(); | ||
|
||
String outputDir = outputDirBase + nameofCurrMethod; | ||
|
||
String[] args = new String[]{ | ||
"-pkey", "test", | ||
"-db", DataState.getInstance().getWorking_db(), | ||
"-o", outputDir, "-cfg", DataState.getInstance().getConfiguration()}; | ||
args = toExecute(args, execArgs, Boolean.FALSE); | ||
|
||
long rtn = 0; | ||
Mirror mirror = new Mirror(); | ||
rtn = mirror.go(args); | ||
long check = MessageCode.PASSWORD_DECRYPT_ISSUE.getLong(); | ||
|
||
// As long as failure isn't about decrypt. | ||
assertFalse("Return Code Failure: " + rtn + " doesn't match: " + check, rtn == check); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters