-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add support to configure system password for Oracle database #10601
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
base: main
Are you sure you want to change the base?
Conversation
…; fix ORACLE_PASSWORD mapping Introduce an independent system user password for Oracle containers and map it correctly to the ORACLE_PASSWORD env. - Add withOraclePassword(String) to configure SYSTEM/SYS password independently from the app user password - Use system password in SID connections (getPassword returns system password in SID mode) - Keep backward compatibility: withPassword also sets system password unless withOraclePassword was called - Update Oracle XE and Oracle Free containers to use the new internal oraclePassword - Add OracleContainerTest to verify system vs app password behavior in SID and non-SID modes This resolves the issue where ORACLE_PASSWORD was effectively bound to the app user password, making it impossible to set the system user password correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for your contribution. Rename the new method to withSystemPassword
instead to make it more aligned with the Oracle database user instead of the env var. Regarding to the comments, please revisit it.
* Password for Oracle system user (e.g. SYSTEM/SYS). Defaults to {@link #APP_USER_PASSWORD} | ||
* for backwards compatibility, but can be customized independently via {@link #withOraclePassword(String)}. | ||
*/ | ||
private String oraclePassword = APP_USER_PASSWORD; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private String oraclePassword = APP_USER_PASSWORD; | |
private String systemPassword = APP_USER_PASSWORD; |
* @param oraclePassword password for SYSTEM/SYS users inside the container | ||
* @return this container instance | ||
*/ | ||
public OracleContainer withOraclePassword(String oraclePassword) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public OracleContainer withOraclePassword(String oraclePassword) { | |
public OracleContainer withSystemPassword(String oraclePassword) { |
* Tracks whether {@link #withOraclePassword(String)} was called to avoid overriding | ||
* the system password when {@link #withPassword(String)} is used for the application user only. | ||
*/ | ||
private boolean oraclePasswordExplicitlySet = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private boolean oraclePasswordExplicitlySet = false; | |
private boolean systemPasswordExplicitlySet = false; |
@@ -31,6 +31,20 @@ private void runTest(OracleContainer container, String databaseName, String user | |||
assertThat(resultSetInt).as("A basic SELECT query succeeds").isEqualTo(1); | |||
} | |||
|
|||
private void runTestSystemUser(OracleContainer container, String databaseName, String username, String password) | |||
throws SQLException { | |||
//Test config was honored |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the comment
assertThat(container.getUsername()).isEqualTo(username); | ||
assertThat(container.getPassword()).isEqualTo(password); | ||
|
||
//Test we can get a connection and execute a system-level command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the comment
|
||
@Test | ||
public void testSeparateSystemAndAppPasswords() throws SQLException { | ||
// SID mode should use system password |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the comment
runTestSystemUser(oracleSid, "xepdb1", "system", "SysP@ss1!"); | ||
} | ||
|
||
// Non-SID mode should use application user's password |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the comment
} | ||
|
||
@Test | ||
public void testSeparateSystemAndAppPasswords() throws SQLException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should have two tests instead?
…; fix ORACLE_PASSWORD mapping
Introduce an independent system user password for Oracle containers and map it correctly to the ORACLE_PASSWORD env.
This resolves the issue where ORACLE_PASSWORD was effectively bound to the app user password, making it impossible to set the system user password correctly.
Summary
Fix Oracle container password handling so
ORACLE_PASSWORD
configures the system user (SYSTEM/SYS) password, not the app user’s password. AddwithOraclePassword(String)
to configure it independently while keeping backward compatibility.Problem
ORACLE_PASSWORD
was populated from the application user password.getUsername()
returnssystem
, butgetPassword()
returned the app user’s password, causing authentication mismatches and preventing a distinct system user password.Changes
withOraclePassword(String oraclePassword)
for SYSTEM/SYS.withPassword(String password)
continues to set the application user password.ORACLE_PASSWORD
← system user password.APP_USER_PASSWORD
← app user password.getUsername()
returnssystem
.getPassword()
now returns the system password.withOraclePassword(...)
is not used,withPassword(...)
sets both the app and system passwords (preserving previous behavior).Why
getPassword()
changedsystem
. Returning the app user’s password was incorrect and led to login failures. Now the password matches the user being used.Affected modules
testcontainers-oracle-xe
testcontainers-oracle-free
Tests
SimpleOracleTest
(no new test classes):Usage examples
Migration / Compatibility
.withPassword(...)
continues to work (sets both passwords unless.withOraclePassword(...)
is used)..withOraclePassword(...)
to set a distinct system password.How to verify locally
./gradlew checkstyleMain checkstyleTest spotlessApply
.\gradlew.bat checkstyleMain checkstyleTest spotlessApply
./gradlew :testcontainers-oracle-xe:test :testcontainers-oracle-free:test
Documentation
ORACLE_PASSWORD
configures the SYSTEM/SYS password.APP_USER_PASSWORD
configures the app user’s password.Changelog entry
withOraclePassword
and fixORACLE_PASSWORD
mapping to system user; use system password in SID mode; maintain backward compatibility withwithPassword
.Related issues