@@ -3,6 +3,21 @@ const { tokenFor, openIdConfiguration } = require('../utils')
33const { reset, expectUser, expectVhost, expectResource, allow, verifyAll } = require ( '../mock_http_backend' )
44const { execSync} = require ( 'child_process' )
55
6+ var container = require ( 'rhea' ) // https://github.com/amqp/rhea
7+ var receivedAmqpMessageCount = 0
8+ var untilConnectionEstablished = new Promise ( ( resolve , reject ) => {
9+ container . on ( 'connection_open' , function ( context ) {
10+ resolve ( )
11+ } )
12+ } )
13+
14+ container . on ( 'message' , function ( context ) {
15+ receivedAmqpMessageCount ++
16+ } )
17+ container . once ( 'sendable' , function ( context ) {
18+ context . sender . send ( { body :'first message' } )
19+ } )
20+
621const profiles = process . env . PROFILES || ""
722var backends = ""
823for ( const element of profiles . split ( " " ) ) {
@@ -39,8 +54,39 @@ describe('Having AMQP 1.0 protocol enabled and the following auth_backends: ' +
3954 }
4055 } )
4156
42- it ( 'can open an AMQP 1.0 connection' , function ( ) {
43- console . log ( execSync ( amqpClientCommand ) . toString ( ) )
57+ it ( 'can open an AMQP 1.0 connection' , async function ( ) {
58+ connection = container . connect (
59+ { 'host' : process . env . RABBITMQ_HOSTNAME || 'rabbitmq' ,
60+ 'port' : process . env . RABBITMQ_AMQP_PORT || 5672 ,
61+ 'username' : process . env . RABBITMQ_AMQP_USERNAME || 'guest' ,
62+ 'password' : process . env . RABBITMQ_AMQP_PASSWORD || 'guest' ,
63+ 'id' : "selenium-connection-id" ,
64+ 'container_id' : "selenium-container-id" ,
65+ 'scheme' : process . env . RABBITMQ_AMQP_SCHEME || 'amqp' ,
66+ //enable_sasl_external:true,
67+
68+ } )
69+ connection . open_receiver ( {
70+ source : 'examples' ,
71+ target : 'receiver-target' ,
72+ name : 'receiver-link'
73+ } )
74+ sender = connection . open_sender ( {
75+ target : 'examples' ,
76+ source : 'sender-source' ,
77+ name : 'sender-link'
78+ } )
79+ await untilConnectionEstablished
80+ var untilMessageReceived = new Promise ( ( resolve , reject ) => {
81+ container . on ( 'message' , function ( context ) {
82+ resolve ( )
83+ } )
84+ } )
85+ sender . send ( { body :'second message' } )
86+ await untilMessageReceived
87+ assert . equal ( 2 , receivedAmqpMessageCount )
88+
89+ //console.log(execSync(amqpClientCommand).toString())
4490 } )
4591
4692 after ( function ( ) {
0 commit comments