Skip to content

Commit

Permalink
Merge pull request #107 from creative-commoners/pulls/2.10/guzzle
Browse files Browse the repository at this point in the history
FIX Update oembed config
  • Loading branch information
GuySartorelli authored May 12, 2022
2 parents 8487b6b + f694530 commit e381c5f
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 e381c5f

Please sign in to comment.