Remove the built in micropub client

This commit is contained in:
Jonny Barnes 2017-10-19 13:36:35 +01:00
parent 9124c481e7
commit dcae136b60
10 changed files with 5 additions and 978 deletions

View file

@ -1,49 +0,0 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
class IndieAuthControllerTest extends TestCase
{
/**
* Test the `start` method redirects to the client on error.
*
* @return void
*/
public function test_indieauthcontroller_begin_auth_flow_redirects_back_to_client_on_error()
{
$response = $this->call('POST', '/indieauth/start', ['me' => 'http://example.org']);
$this->assertSame(route('micropub-client'), $response->headers->get('Location'));
}
/**
* Now we test the `start` method as a whole.
*
* @return void
*/
public function test_indieauthcontroller_begin_auth_redirects_to_endpoint()
{
$response = $this->call('POST', '/indieauth/start', ['me' => config('app.url')]);
$this->assertSame(
'https://indieauth.com/auth?me=',
substr($response->headers->get('Location'), 0, 30)
);
}
/**
* Test the `callback` method.
*
* @return void
*/
public function test_indieauthcontroller_callback_method_gives_error_with_mismatched_state()
{
$response = $this->withSession(['state' => 'state-session'])
->call(
'GET',
'indieauth/callback',
['me', config('app.url'), 'state' => 'request-session']
);
$response->assertSessionHas(['error' => 'Invalid <code>state</code> value returned from indieauth server']);
}
}

View file

@ -1,55 +0,0 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
use GuzzleHttp\Client;
use GuzzleHttp\Middleware;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Handler\MockHandler;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class MicropubClientControllerTest extends TestCase
{
use DatabaseTransactions;
public function test_json_syntax_is_created_correctly()
{
/*
$container = [];
$history = Middleware::history($container);
$mock = new MockHandler([
new Response(201, ['Location' => 'http://example.org/a'], 'Created'),
]);
$stack = HandlerStack::create($mock);
// add the history middleware to the stack
$stack->push($history);
$client = new Client(['handler' => $stack]);
$this->app->instance(Client::class, $client);
$response = $this->post(
'/micropub',
[
'content' => 'Hello Fred',
'in-reply-to' => 'https://fredbloggs.com/note/abc',
'mp-syndicate-to' => ['https://twitter.com/jonnybarnes', 'https://facebook.com/jonnybarnes'],
]
);
$expected = '{"type":["h-entry"],"properties":{"content":["Hello Fred"],"in-reply-to":["https:\/\/fredbloggs.com\/note\/abc"],"mp-syndicate-to":["https:\/\/twitter.com\/jonnybarnes","https:\/\/facebook.com\/jonnybarnes"]}}';
if (count($container) === 0) {
$this->fail();
}
foreach ($container as $transaction) {
$this->assertEquals($expected, $transaction['request']->getBody()->getContents());
}
*/
$this->assertTrue(true);
}
}

View file

@ -24,8 +24,8 @@ class TokenEndpointTest extends TestCase
$response = $this->post('/api/token', [
'me' => config('app.url'),
'code' => 'abc123',
'redirect_uri' => route('indieauth-callback'),
'client_id' => route('micropub-client'),
'redirect_uri' => config('app.url') . '/indieauth-callback',
'client_id' => config('app.url') . '/micropub-client',
'state' => mt_rand(1000, 10000),
]);
parse_str($response->content(), $output);

View file

@ -1,75 +0,0 @@
<?php
namespace Tests\Unit;
use Tests\TestCase;
use App\Services\IndieAuthService;
class IndieAuthServiceTest extends TestCase
{
/**
* Test the getAuthorizationEndpoint method.
*
* @return void
*/
public function test_indieauthservice_getauthorizationendpoint_method()
{
$service = new IndieAuthService();
$result = $service->getAuthorizationEndpoint(config('app.url'));
$this->assertEquals('https://indieauth.com/auth', $result);
}
/**
* Test the getAuthorizationEndpoint method returns null on failure.
*
* @return void
*/
public function test_indieauthservice_getauthorizationendpoint_method_returns_null_on_failure()
{
$service = new IndieAuthService();
$result = $service->getAuthorizationEndpoint('http://example.org');
$this->assertEquals(null, $result);
}
/**
* Test that the Service build the correct redirect URL.
*
* @return void
*/
public function test_indieauthservice_builds_correct_redirect_url()
{
$service = new IndieAuthService();
$result = $service->buildAuthorizationURL(
'https://indieauth.com/auth',
config('app.url')
);
$this->assertEquals(
'https://indieauth.com/auth?me=',
substr($result, 0, 30)
);
}
/**
* Test the getTokenEndpoint method.
*
* @return void
*/
public function test_indieauthservice_gettokenendpoint_method()
{
$service = new IndieAuthService();
$result = $service->getTokenEndpoint(config('app.url'));
$this->assertEquals(config('app.url') . '/api/token', $result);
}
/**
* Test the discoverMicropubEndpoint method.
*
* @return void
*/
public function test_indieauthservice_discovermicropubendpoint_method()
{
$service = new IndieAuthService();
$result = $service->discoverMicropubEndpoint(config('app.url'));
$this->assertEquals(config('app.url') . '/api/post', $result);
}
}