|
16 | 16 | use Symfony\Component\Mailer\Bridge\MicrosoftGraph\TokenManager; |
17 | 17 | use Symfony\Component\Mailer\Bridge\MicrosoftGraph\Transport\MicrosoftGraphApiTransport; |
18 | 18 | use Symfony\Component\Mailer\Bridge\MicrosoftGraph\Transport\MicrosoftGraphTransportFactory; |
| 19 | +use Symfony\Component\Mailer\Exception\InvalidArgumentException; |
19 | 20 | use Symfony\Component\Mailer\Test\AbstractTransportFactoryTestCase; |
20 | 21 | use Symfony\Component\Mailer\Test\IncompleteDsnTestTrait; |
21 | 22 | use Symfony\Component\Mailer\Transport\Dsn; |
@@ -74,4 +75,23 @@ public static function incompleteDsnProvider(): iterable |
74 | 75 | yield [new Dsn('microsoft+graphapi', 'default', self::USER, self::PASSWORD)]; |
75 | 76 | yield [new Dsn('microsoft+graphapi', 'non-default', self::USER, self::PASSWORD, null, ['tenantId' => self::TENANT])]; |
76 | 77 | } |
| 78 | + |
| 79 | + /** @dataProvider invalidHttpDsnProvider */ |
| 80 | + public function testValidatesHttpNotProvided(string $graph, string $auth, string $failingType) |
| 81 | + { |
| 82 | + $factory = $this->getFactory(); |
| 83 | + $dsn = new Dsn('microsoft+graphapi', $graph, self::USER, self::PASSWORD, null, ['tenantId' => self::TENANT, 'authEndpoint' => $auth]); |
| 84 | + |
| 85 | + $this->expectException(InvalidArgumentException::class); |
| 86 | + $this->expectExceptionMessage($failingType.' endpoint needs to be provided without http(s)://.'); |
| 87 | + $factory->create($dsn); |
| 88 | + } |
| 89 | + |
| 90 | + public static function invalidHttpDsnProvider(): iterable |
| 91 | + { |
| 92 | + yield ['http://graph', 'auth', 'Graph']; |
| 93 | + yield ['https://graph', 'auth', 'Graph']; |
| 94 | + yield ['graph', 'http://auth', 'Auth']; |
| 95 | + yield ['graph', 'https://auth', 'Auth']; |
| 96 | + } |
77 | 97 | } |
0 commit comments