This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||
2 | namespace NeedleProject\LaravelRabbitMq\Builder; |
||
3 | |||
4 | use PHPUnit\Framework\TestCase; |
||
5 | |||
6 | class ContainerBuilderTest extends TestCase |
||
7 | { |
||
8 | public function testPublisher() |
||
9 | { |
||
10 | $containerBuilder = new ContainerBuilder(); |
||
11 | $container = $containerBuilder->createContainer([ |
||
12 | 'connections' => [ |
||
13 | 'foo' => [] |
||
14 | ], |
||
15 | 'queues' => [], |
||
16 | 'consumers' => [], |
||
17 | 'exchanges' => [ |
||
18 | 'my.exchange' => [ |
||
19 | // used connection for the producer |
||
20 | 'connection' => 'foo', |
||
21 | 'name' => 'the.exchange.name', |
||
22 | 'attributes' => [ |
||
23 | 'exchange_type' => 'topic' |
||
24 | ] |
||
25 | ] |
||
26 | ], |
||
27 | 'publishers' => [ |
||
28 | 'fooPublisher' => 'my.exchange' |
||
29 | ] |
||
30 | ]); |
||
31 | |||
32 | $this->assertEquals(1, count($container->getPublishers())); |
||
33 | $this->assertEquals( |
||
34 | 'my.exchange', |
||
35 | $container->getPublisher('fooPublisher')->getAliasName() |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
36 | ); |
||
37 | } |
||
38 | |||
39 | public function testBadConnectionReferenceForExchange() |
||
40 | { |
||
41 | $containerBuilder = new ContainerBuilder(); |
||
42 | |||
43 | $this->expectException(\RuntimeException::class); |
||
44 | |||
45 | $containerBuilder->createContainer([ |
||
46 | 'connections' => [ |
||
47 | 'foo' => [] |
||
48 | ], |
||
49 | 'queues' => [], |
||
50 | 'consumers' => [], |
||
51 | 'exchanges' => [ |
||
52 | 'my.exchange' => [ |
||
53 | 'connection' => 'un-existent', |
||
54 | 'name' => 'the.exchange.name', |
||
55 | 'attributes' => [ |
||
56 | 'exchange_type' => 'topic' |
||
57 | ] |
||
58 | ] |
||
59 | ], |
||
60 | 'publishers' => [ |
||
61 | 'fooPublisher' => 'my.exchange' |
||
62 | ] |
||
63 | ]); |
||
64 | } |
||
65 | |||
66 | public function testConsumer() |
||
67 | { |
||
68 | $containerBuilder = new ContainerBuilder(); |
||
69 | $container = $containerBuilder->createContainer([ |
||
70 | 'connections' => [ |
||
71 | 'foo' => [] |
||
72 | ], |
||
73 | 'exchanges' => [], |
||
74 | 'consumers' => [ |
||
75 | 'my-consumer' => [ |
||
76 | 'queue' => 'my.queue', |
||
77 | 'prefetch_count' => 1, |
||
78 | 'global_prefetch' => true, |
||
79 | 'message_processor' => \NeedleProject\LaravelRabbitMq\Processor\CliOutputProcessor::class |
||
80 | ] |
||
81 | ], |
||
82 | 'queues' => [ |
||
83 | 'my.queue' => [ |
||
84 | // used connection for the producer |
||
85 | 'connection' => 'foo', |
||
86 | 'name' => 'my.queue', |
||
87 | 'attributes' => [] |
||
88 | ] |
||
89 | ], |
||
90 | 'publishers' => [] |
||
91 | ]); |
||
92 | |||
93 | $this->assertEquals(1, count($container->getConsumers())); |
||
94 | $this->assertEquals( |
||
95 | 'my.queue', |
||
96 | $container->getConsumer('my-consumer')->getAliasName() |
||
97 | ); |
||
98 | } |
||
99 | |||
100 | public function testQueueBadConnection() |
||
101 | { |
||
102 | $containerBuilder = new ContainerBuilder(); |
||
103 | |||
104 | $this->expectException(\RuntimeException::class); |
||
105 | |||
106 | $containerBuilder->createContainer([ |
||
107 | 'connections' => [ |
||
108 | 'foo' => [] |
||
109 | ], |
||
110 | 'exchanges' => [], |
||
111 | 'consumers' => [ |
||
112 | 'my-consumer' => [ |
||
113 | 'queue' => 'my.queue', |
||
114 | 'prefetch_count' => 1, |
||
115 | 'message_processor' => \NeedleProject\LaravelRabbitMq\Processor\CliOutputProcessor::class |
||
116 | ] |
||
117 | ], |
||
118 | 'queues' => [ |
||
119 | 'my.queue' => [ |
||
120 | // used connection for the producer |
||
121 | 'connection' => 'bar', |
||
122 | 'name' => 'my.queue', |
||
123 | 'attributes' => [] |
||
124 | ] |
||
125 | ], |
||
126 | 'publishers' => [] |
||
127 | ]); |
||
128 | } |
||
129 | |||
130 | public function testBadConsumerReference() |
||
131 | { |
||
132 | $containerBuilder = new ContainerBuilder(); |
||
133 | |||
134 | $this->expectException(\RuntimeException::class); |
||
135 | |||
136 | $containerBuilder->createContainer([ |
||
137 | 'connections' => [ |
||
138 | 'foo' => [] |
||
139 | ], |
||
140 | 'exchanges' => [], |
||
141 | 'consumers' => [ |
||
142 | 'my-consumer' => [ |
||
143 | 'queue' => 'my.queue', |
||
144 | 'prefetch_count' => 1, |
||
145 | 'global_prefetch' => true, |
||
146 | 'message_processor' => \NeedleProject\LaravelRabbitMq\Processor\CliOutputProcessor::class |
||
147 | ] |
||
148 | ], |
||
149 | 'queues' => [ |
||
150 | 'my.queue.typo' => [ |
||
151 | // used connection for the producer |
||
152 | 'connection' => 'foo', |
||
153 | 'name' => 'my.queue', |
||
154 | 'attributes' => [] |
||
155 | ] |
||
156 | ], |
||
157 | 'publishers' => [] |
||
158 | ]); |
||
159 | } |
||
160 | |||
161 | public function testBadPublisherReference() |
||
162 | { |
||
163 | $containerBuilder = new ContainerBuilder(); |
||
164 | |||
165 | $this->expectException(\RuntimeException::class); |
||
166 | |||
167 | $containerBuilder->createContainer([ |
||
168 | 'connections' => [ |
||
169 | 'foo' => [] |
||
170 | ], |
||
171 | 'queues' => [], |
||
172 | 'consumers' => [], |
||
173 | 'exchanges' => [ |
||
174 | 'my.exchange' => [ |
||
175 | // used connection for the producer |
||
176 | 'connection' => 'foo', |
||
177 | 'name' => 'the.exchange.name', |
||
178 | 'attributes' => [ |
||
179 | 'exchange_type' => 'topic' |
||
180 | ] |
||
181 | ] |
||
182 | ], |
||
183 | 'publishers' => [ |
||
184 | 'fooPublisher' => 'my.exchange.typo' |
||
185 | ] |
||
186 | ]); |
||
187 | } |
||
188 | |||
189 | public function testQueuePublisherReference() |
||
190 | { |
||
191 | $containerBuilder = new ContainerBuilder(); |
||
192 | $container = $containerBuilder->createContainer([ |
||
193 | 'connections' => [ |
||
194 | 'foo' => [] |
||
195 | ], |
||
196 | 'queues' => [ |
||
197 | 'a.queue' => [ |
||
198 | // used connection for the producer |
||
199 | 'connection' => 'foo', |
||
200 | 'name' => 'a.queue.name', |
||
201 | 'attributes' => [ |
||
202 | ] |
||
203 | ] |
||
204 | ], |
||
205 | 'consumers' => [], |
||
206 | 'exchanges' => [], |
||
207 | 'publishers' => [ |
||
208 | 'fooPublisher' => 'a.queue' |
||
209 | ] |
||
210 | ]); |
||
211 | |||
212 | |||
213 | $this->assertEquals(1, count($container->getPublishers())); |
||
214 | $this->assertEquals( |
||
215 | 'a.queue', |
||
216 | $container->getPublisher('fooPublisher')->getAliasName() |
||
217 | ); |
||
218 | } |
||
219 | } |
||
220 |