Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Update oembed config #107

Merged
merged 1 commit into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
}