Skip to content

Commit

Permalink
Merge pull request #3 from SmartSteelTechnologies/use-username-passwo…
Browse files Browse the repository at this point in the history
…rd-authentication-in-integration-test

Use username/password authentication to test IBM MQ in the integration tests
  • Loading branch information
theodore-evans authored Dec 20, 2023
2 parents 0827b6b + 203968c commit 9f53dd5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ public class AbstractJMSContextIT {

private static final String QMGR_NAME = "MYQMGR";
private static final String CHANNEL_NAME = "DEV.APP.SVRCONN";
protected static final String APP_PASSWORD = "MySuperSecretPassword";
private static final String ADMIN_PASSWORD = "MyAdminPassword";

@ClassRule
public static GenericContainer<?> mqContainer = new GenericContainer<>("icr.io/ibm-messaging/mq:latest")
.withEnv("LICENSE", "accept")
.withEnv("MQ_QMGR_NAME", QMGR_NAME)
.withEnv("MQ_APP_PASSWORD", APP_PASSWORD)
.withEnv("MQ_ADMIN_PASSWORD", ADMIN_PASSWORD)
.withEnv("MQ_ENABLE_EMBEDDED_WEB_SERVER", "false")
.withExposedPorts(1414);

Expand All @@ -72,7 +76,7 @@ public JMSContext getJmsContext() throws Exception {
mqcf.setQueueManager(QMGR_NAME);
mqcf.setConnectionNameList(getConnectionName());

jmsContext = mqcf.createContext();
jmsContext = mqcf.createContext("app", APP_PASSWORD);
}

return jmsContext;
Expand Down Expand Up @@ -127,7 +131,8 @@ public void putAllMessagesToQueue(final String queueName, final List<Message> me
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, getChannelName());
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, getQmgrName());
cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, false);
cf.setStringProperty(WMQConstants.USERID, "app");
cf.setStringProperty(WMQConstants.PASSWORD, APP_PASSWORD);

connection = cf.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Expand Down Expand Up @@ -163,7 +168,8 @@ public List<Message> getAllMessagesFromQueue(final String queueName) throws JMSE
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, getChannelName());
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, getQmgrName());
cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, false);
cf.setStringProperty(WMQConstants.USERID, "app");
cf.setStringProperty(WMQConstants.PASSWORD, APP_PASSWORD);

connection = cf.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ private Map<String, String> createDefaultConnectorProperties() {
props.put("mq.channel.name", getChannelName());
props.put("mq.queue", MQ_QUEUE);
props.put("mq.user.authentication.mqcsp", "false");
props.put("mq.user.name", "app");
props.put("mq.password", APP_PASSWORD);
props.put("mq.user.authentication.mqcsp", "true");
return props;
}

Expand Down

0 comments on commit 9f53dd5

Please sign in to comment.