Skip to content

Commit

Permalink
FIX Update oembed config
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed May 12, 2022
1 parent 8487b6b commit c6e03df
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
14 changes: 2 additions & 12 deletions _config/oembed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ Only:
---
SilverStripe\Core\Injector\Injector:
# Configure the CWP proxy if defined
Embed\Http\DispatcherInterface:
class: Embed\Http\CurlDispatcher
Psr\Http\Client\ClientInterface.oembed:
constructor:
config:
# CURLOPT_PROXY = 10004
10004: '`SS_OUTBOUND_PROXY`'
# CURLOPT_PROXYPORT = 59
59: '`SS_OUTBOUND_PROXY_PORT`'

# Provide dispatcher to Embeddable implementations
SilverStripe\View\Embed\Embeddable:
properties:
Dispatcher: '%$Embed\Http\DispatcherInterface'
- proxy: '`SS_OUTBOUND_PROXY`:`SS_OUTBOUND_PROXY_PORT`'
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"require": {
"php": "^7.3 || ^8.0",
"silverstripe/framework": "^4.10",
"silverstripe/framework": "^4.11",
"silverstripe/admin": "^1.10",
"silverstripe/hybridsessions": "^2",
"silverstripe/environmentcheck": "^2",
Expand Down
28 changes: 28 additions & 0 deletions tests/OEmbedTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace CWP\Core\Tests;

use Embed\Http\Crawler;
use GuzzleHttp\Client;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\SapphireTest;

class OEmbedTest extends SapphireTest
{
/**
* Ensure that the Psr\Http\Client\ClientInterface.oembed created is a
* GuzzleHttp\Client which can have the CWP outband proxy configuration applied to it
*
* This is to ensure the config in cwp-core/_config/oembed.yml aligns with the
* configured ClientInterface in the required version of framework
*/
public function testGuzzleProxyConfig()
{
$reflClass = new \ReflectionClass(Crawler::class);
$reflProperty = $reflClass->getProperty('client');
$reflProperty->setAccessible(true);
$crawler = Injector::inst()->get(Crawler::class);
$client = $reflProperty->getValue($crawler);
$this->assertSame(Client::class, get_class($client));
}
}

0 comments on commit c6e03df

Please sign in to comment.