Skip to content

Commit

Permalink
Merge pull request #1418 from cultuurnet/III-5712-update-uri-regex
Browse files Browse the repository at this point in the history
III-5712 update uri regex for hashtag
  • Loading branch information
JonasVHG authored Jul 25, 2023
2 parents 4702656 + b4580b7 commit ba1454c
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 16 deletions.
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion features/event/attendance-mode.feature
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ Feature: Test event attendanceMode property
{
"schemaErrors": [
{
"error": "The string should match pattern: ^http[s]?:\\/\\/\\w",
"error": "The string should match pattern: ^https?:\\/\\/[\\w\\-\\.]+\\.\\w{2,}(\\/.*)?$",
"jsonPointer": "/onlineUrl"
}
],
Expand Down
2 changes: 1 addition & 1 deletion features/event/booking-info.feature
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ Feature: Test the UDB3 events API
"status":400,
"schemaErrors": [
{
"error": "The string should match pattern: ^http[s]?:\\/\\/\\w",
"error": "The string should match pattern: ^https?:\\/\\/[\\w\\-\\.]+\\.\\w{2,}(\\/.*)?$",
"jsonPointer": "/url"
}
]
Expand Down
2 changes: 1 addition & 1 deletion features/organizer/url.feature
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Feature: Test organizer url property
"status": 400,
"schemaErrors": [
{
"error": "The string should match pattern: ^http[s]?:\\/\\/\\w",
"error": "The string should match pattern: ^https?:\\/\\/[\\w\\-\\.]+\\.\\w{2,}(\\/.*)?$",
"jsonPointer": "/url"
}
]
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/Event/ImportEventRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3028,7 +3028,7 @@ public function it_throws_if_onlineUrl_has_wrong_format(): void
$expectedErrors = [
new SchemaError(
'/onlineUrl',
'The string should match pattern: ^http[s]?:\/\/\w'
'The string should match pattern: ^https?:\/\/[\w\-\.]+\.\w{2,}(\/.*)?$'
),
];

Expand Down
2 changes: 1 addition & 1 deletion tests/Http/Event/UpdateOnlineUrlRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function onlineUrlProvider(): array
[
'onlineUrl' => 'rtp://www.publiq.be/livestream',
],
new SchemaError('/onlineUrl', 'The string should match pattern: ^http[s]?:\/\/\w'),
new SchemaError('/onlineUrl', 'The string should match pattern: ^https?:\/\/[\w\-\.]+\.\w{2,}(\/.*)?$'),
],
];
}
Expand Down
43 changes: 37 additions & 6 deletions tests/Http/Offer/UpdateBookingInfoRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ protected function setUp(): void
*/
public function it_handles_updating_the_booking_info_of_an_offer(
string $offerType,
string $url,
AbstractUpdateBookingInfo $updateBookingInfo
): void {
$updateBookingInfoRequest = $this->psr7RequestBuilder
Expand All @@ -62,7 +63,7 @@ public function it_handles_updating_the_booking_info_of_an_offer(
->withJsonBodyFromArray(
[
'bookingInfo' => [
'url' => 'https://www.publiq.be/',
'url' => $url,
'urlLabel' => ['nl' => 'Publiq vzw'],
'phone' => '02/1232323',
'email' => 'info@publiq.be',
Expand Down Expand Up @@ -90,8 +91,20 @@ public function it_handles_updating_the_booking_info_of_an_offer(

public function offerTypeDataProvider(): array
{
$bookingInfo = new BookingInfo(
'https://www.publiq.be/',
$basicUrl = 'https://www.publiq.be/';
$specialCharactersUrl = 'https://publiq-vzw.com/Inschrijven.aspx?ReservatieCat=2#/inschrijven/activiteiten';

$bookingInfoBasicUrl = new BookingInfo(
$basicUrl,
new MultilingualString(new Language('nl'), new StringLiteral('Publiq vzw')),
'02/1232323',
'info@publiq.be',
\DateTimeImmutable::createFromFormat(\DATE_ATOM, '2023-01-01T00:00:00+01:00'),
\DateTimeImmutable::createFromFormat(\DATE_ATOM, '2028-01-31T23:59:59+01:00')
);

$bookingInfoSpecialCharactersUrl = new BookingInfo(
$specialCharactersUrl,
new MultilingualString(new Language('nl'), new StringLiteral('Publiq vzw')),
'02/1232323',
'info@publiq.be',
Expand All @@ -102,16 +115,34 @@ public function offerTypeDataProvider(): array
return [
[
'offerType' => 'events',
'url' => $basicUrl,
'updateBookingInfo' => new EventUpdateBookingInfo(
self::OFFER_ID,
$bookingInfoBasicUrl
),
],
[
'offerType' => 'places',
'url' => $basicUrl,
'updateBookingInfo' => new PlaceUpdateBookingInfo(
self::OFFER_ID,
$bookingInfoBasicUrl
),
],
[
'offerType' => 'events',
'url' => $specialCharactersUrl,
'updateBookingInfo' => new EventUpdateBookingInfo(
self::OFFER_ID,
$bookingInfo
$bookingInfoSpecialCharactersUrl
),
],
[
'offerType' => 'places',
'url' => $specialCharactersUrl,
'updateBookingInfo' => new PlaceUpdateBookingInfo(
self::OFFER_ID,
$bookingInfo
$bookingInfoSpecialCharactersUrl
),
],
];
Expand Down Expand Up @@ -179,7 +210,7 @@ public function provideApiProblemTestData(): Iterator
'schemaErrors' => [
new SchemaError(
'/url',
'The string should match pattern: ^http[s]?:\/\/\w'
'The string should match pattern: ^https?:\/\/[\w\-\.]+\.\w{2,}(\/.*)?$'
),
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function it_requires_a_valid_url(): void

$this->assertCallableThrowsApiProblem(
ApiProblem::bodyInvalidData(
new SchemaError('/url/0', 'The string should match pattern: ^http[s]?:\/\/\w')
new SchemaError('/url/0', 'The string should match pattern: ^https?:\/\/[\w\-\.]+\.\w{2,}(\/.*)?$')
),
fn () => $this->updateContactPointRequestHandler->handle($updateUrlRequest)
);
Expand Down

0 comments on commit ba1454c

Please sign in to comment.