Skip to content

Commit be333a5

Browse files
authored
Avoid overwriting variable values with tokens in prepareModel (#960)
* Allow for unspecified or non-existent variables file * JIRA WDT-572 - Added specific exception type for prepare model * JIRA WDT-572 - Revised messages for prepareModel * Add methods to check token-only strings * Move check for secret overwriting a property value to credential injector * Extract ModelPreparer class from prepare_model class to allow unit tests * Extract ModelPreparer class from prepare_model class to allow unit tests * Corrected test messages * Maintain variable keys for removal in credential injector * Added config directory for use with unit tests * Removed unused logger * Added a unit test for prepareModel * Moved unit test to package, disabled logging during test * Revised test to verify unchanged variable token * Revised test to verify variable and secret files * Cast os.environ arguments to str to avoid IDE analysis issue * Create unit test base class; create config in output directory; check prepared variables and secrets * Removed unused injector configuration files * Correct argument count for ModelPreparer * Clear unused properties after prepare and filter, rather than during prepare * Support multiple variable tokens in a single value * Changed method name and added description * Allow variable argument list in match * Use internal method to write properties to avoid comment and escaping, and to preserve order * Correct variable name
1 parent 331ef80 commit be333a5

File tree

16 files changed

+978
-494
lines changed

16 files changed

+978
-494
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates.
3+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
*/
5+
package oracle.weblogic.deploy.prepare;
6+
7+
import oracle.weblogic.deploy.exception.BundleAwareException;
8+
import oracle.weblogic.deploy.exception.ExceptionHelper;
9+
10+
/**
11+
* The exception used by the prepare model components.
12+
*/
13+
public class PrepareException extends BundleAwareException {
14+
private static final long serialVersionUID = 1L;
15+
16+
/**
17+
* Constructs a default exception.
18+
*/
19+
public PrepareException() {
20+
// default constructor
21+
}
22+
23+
/**
24+
* Constructs a new exception with the specified message id.
25+
*
26+
* @param messageID the message ID
27+
*/
28+
public PrepareException(String messageID) {
29+
super(messageID);
30+
}
31+
32+
/**
33+
* Constructs a new exception with the specified message id and parameters.
34+
*
35+
* @param messageID the message ID
36+
* @param params the parameters to use to fill in the message tokens
37+
*/
38+
public PrepareException(String messageID, Object... params) {
39+
super(messageID, params);
40+
}
41+
42+
/**
43+
* Constructs a new exception with the specified message id and cause.
44+
*
45+
* @param messageID the message ID
46+
* @param cause the exception that triggered the creation of this exception
47+
*/
48+
public PrepareException(String messageID, Throwable cause) {
49+
super(messageID, cause);
50+
}
51+
52+
/**
53+
* Constructs a new exception with passed message id, cause, and parameters.
54+
*
55+
* @param messageID the message ID
56+
* @param cause the exception that triggered the creation of this exception
57+
* @param params the parameters to use to fill in the message tokens
58+
*/
59+
public PrepareException(String messageID, Throwable cause, Object... params) {
60+
super(messageID, cause, params);
61+
}
62+
63+
/**
64+
* Constructs a new exception with the specified cause.
65+
*
66+
* @param cause the exception that triggered the creation of this exception
67+
*/
68+
public PrepareException(Throwable cause) {
69+
super(cause);
70+
}
71+
72+
/**
73+
* {@inheritDoc}
74+
*/
75+
@Override
76+
public String getBundleName() {
77+
return ExceptionHelper.getResourceBundleName();
78+
}
79+
}

0 commit comments

Comments
 (0)