diff --git a/localSetup/projects/nginx/templates/hub.conf.template b/localSetup/projects/nginx/templates/hub.conf.template index 7ca0dac526..5443078c7a 100644 --- a/localSetup/projects/nginx/templates/hub.conf.template +++ b/localSetup/projects/nginx/templates/hub.conf.template @@ -3,6 +3,7 @@ server { server_name hub.${EDLIB_ROOT_DOMAIN} + hub-test.${EDLIB_ROOT_DOMAIN} hub-vite-hmr.${EDLIB_ROOT_DOMAIN} ~^edlib-hub[a-z0-9-]+\.ngrok\.dev$ ; @@ -29,6 +30,27 @@ server { } } +server { + listen 443 ssl; + server_name hub-test.${EDLIB_ROOT_DOMAIN}; + + ssl_certificate /etc/ssl/private/cerpus.crt; + ssl_certificate_key /etc/ssl/private/cerpus.key; + + root /srv/www/hub/public; + + location / { + try_files $uri /index.php$is_args$args; + } + + location ~ \.php$ { + include fastcgi.conf; + fastcgi_pass hub:9000; + fastcgi_param APP_ENV 'testing'; + fastcgi_param APP_URL https://hub-test.${EDLIB_ROOT_DOMAIN}; + } +} + map $http_upgrade $connection_upgrade { default upgrade; '' close; diff --git a/scripts/update-host-file.sh b/scripts/update-host-file.sh index b724e74fd8..10ed086b76 100755 --- a/scripts/update-host-file.sh +++ b/scripts/update-host-file.sh @@ -12,6 +12,7 @@ $ip\tca.$root $ip\tdocs.$root $ip\tfacade.$root $ip\thub.$root +$ip\thub-test.$root $ip\thub-vite-hmr.$root $ip\tmailpit.$root $ip\tmoodle.$root diff --git a/sourcecode/hub/.env.testing b/sourcecode/hub/.env.testing new file mode 100644 index 0000000000..e856e77cb6 --- /dev/null +++ b/sourcecode/hub/.env.testing @@ -0,0 +1,16 @@ +APP_KEY=base64:VaYy17usaDFlRZRAO9OQukSy6rpcCKlooovrAc55x6s= +APP_NAME=EdlibTest +APP_URL=https://hub-test.edlib.test +BCRYPT_ROUNDS=4 +DB_HOST=postgres +DB_DATABASE=hub_test +DB_USERNAME=postgres +DB_PASSWORD=thepgpassword +FEATURE_RESET_PASSWORD_ENABLED=true +FEATURE_SIGNUP_ENABLED=true +MAIL_MAILER=array +MEILISEARCH_HOST=http://meilisearch:7700 +MEILISEARCH_KEY=masterkey1234567 +QUEUE_CONNECTION=sync +SCOUT_PREFIX=hub_test_ +TELESCOPE_ENABLED=false diff --git a/sourcecode/hub/README.md b/sourcecode/hub/README.md index 7821927cb5..c5042d2594 100644 --- a/sourcecode/hub/README.md +++ b/sourcecode/hub/README.md @@ -15,12 +15,9 @@ TODO: write the rest of the README ./chromedriver --allowed-ips= --allowed-origins='*' ``` -4. Make sure APP_URL is set to the correct location. It should be the URL you - open in your browser for development. +4. Make sure loads in your browser. It should look + the same as the regular hub, but should not share data with it. - ```dotenv - APP_URL=https://hub.edlib.test - ``` 5. Run the browser tests. ## Using ngrok for development diff --git a/sourcecode/hub/phpunit.xml b/sourcecode/hub/phpunit.xml index bbcf7dadcc..b6005da1ed 100644 --- a/sourcecode/hub/phpunit.xml +++ b/sourcecode/hub/phpunit.xml @@ -18,22 +18,9 @@ + - - - - - - - - - - - - - - diff --git a/sourcecode/hub/tests/Browser/AdminTest.php b/sourcecode/hub/tests/Browser/AdminTest.php index 57c74710f7..5786a6f11e 100644 --- a/sourcecode/hub/tests/Browser/AdminTest.php +++ b/sourcecode/hub/tests/Browser/AdminTest.php @@ -6,14 +6,11 @@ use App\Models\LtiTool; use App\Models\User; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\DuskTestCase; final class AdminTest extends DuskTestCase { - use DatabaseMigrations; - public function testCanRebuildIndex(): void { $this->browse(function (Browser $browser) { diff --git a/sourcecode/hub/tests/Browser/ContentTest.php b/sourcecode/hub/tests/Browser/ContentTest.php index 6bfd04678b..c2820cc1f9 100644 --- a/sourcecode/hub/tests/Browser/ContentTest.php +++ b/sourcecode/hub/tests/Browser/ContentTest.php @@ -5,14 +5,11 @@ namespace Tests\Browser; use App\Models\Content; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\DuskTestCase; final class ContentTest extends DuskTestCase { - use DatabaseMigrations; - public function testPreviewsContent(): void { $content = Content::factory() diff --git a/sourcecode/hub/tests/Browser/UserTest.php b/sourcecode/hub/tests/Browser/UserTest.php index a5f3732685..36f2b3a8e1 100644 --- a/sourcecode/hub/tests/Browser/UserTest.php +++ b/sourcecode/hub/tests/Browser/UserTest.php @@ -6,15 +6,12 @@ use App\Models\Content; use App\Models\User; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Support\Facades\Hash; use Laravel\Dusk\Browser; use Tests\DuskTestCase; final class UserTest extends DuskTestCase { - use DatabaseMigrations; - public function testUserCanSignUp(): void { $this->browse(function (Browser $browser) { diff --git a/sourcecode/hub/tests/DuskTestCase.php b/sourcecode/hub/tests/DuskTestCase.php index 082414058f..9a3f87285b 100644 --- a/sourcecode/hub/tests/DuskTestCase.php +++ b/sourcecode/hub/tests/DuskTestCase.php @@ -6,6 +6,7 @@ use Facebook\WebDriver\Remote\DesiredCapabilities; use Facebook\WebDriver\Remote\RemoteWebDriver; +use Illuminate\Foundation\Testing\DatabaseTruncation; use Laravel\Dusk\TestCase as BaseTestCase; use function assert; @@ -15,6 +16,7 @@ abstract class DuskTestCase extends BaseTestCase { use CreatesApplication; + use DatabaseTruncation; /** * Create the RemoteWebDriver instance. diff --git a/sourcecode/hub/tests/Feature/LtiPlatformTest.php b/sourcecode/hub/tests/Feature/LtiPlatformTest.php index e2360ac853..9f15548c0f 100644 --- a/sourcecode/hub/tests/Feature/LtiPlatformTest.php +++ b/sourcecode/hub/tests/Feature/LtiPlatformTest.php @@ -53,7 +53,7 @@ public function testItemSelectionLaunchContainsPlatformDetails(): void $this->assertSame('Edlib', $request->get('tool_consumer_info_product_family_code')); $this->assertSame('3', $request->get('tool_consumer_info_version')); $this->assertSame('EdlibTest', $request->get('tool_consumer_instance_name')); - $this->assertSame('https://hub.edlib.test/', $request->get('tool_consumer_instance_url')); + $this->assertSame('https://hub-test.edlib.test', $request->get('tool_consumer_instance_url')); } public function testItemSelectionLaunchContainsLocale(): void diff --git a/sourcecode/hub/tests/Feature/LtiToolTest.php b/sourcecode/hub/tests/Feature/LtiToolTest.php index 813ae5b4ae..14625808e7 100644 --- a/sourcecode/hub/tests/Feature/LtiToolTest.php +++ b/sourcecode/hub/tests/Feature/LtiToolTest.php @@ -32,7 +32,7 @@ public function testCookieCheckIsTransparentWhenCookiesAllowed(): void $platform = LtiPlatform::factory()->create(); $request = $this->oauthSigner->sign( - new Request('POST', 'https://hub.edlib.test/lti/1.1/select', [ + new Request('POST', 'https://hub-test.edlib.test/lti/1.1/select', [ 'content_item_return_url' => 'http://example.com/', 'lti_message_type' => 'ContentItemSelectionRequest', ]), @@ -53,7 +53,7 @@ public function testCookieCheckIsTransparentWhenCookiesAllowed(): void ->assertLocation('/lti/1.1/select'); $this->post('/lti/1.1/select', $request->toArray()) - ->assertRedirect('https://hub.edlib.test/content'); + ->assertRedirect('https://hub-test.edlib.test/content'); } public function testCookieCheckShowsCountermeasuresWhenCookiesNotAllowed(): void @@ -61,7 +61,7 @@ public function testCookieCheckShowsCountermeasuresWhenCookiesNotAllowed(): void $platform = LtiPlatform::factory()->create(); $request = $this->oauthSigner->sign( - new Request('POST', 'https://hub.edlib.test/lti/1.1/select', [ + new Request('POST', 'https://hub-test.edlib.test/lti/1.1/select', [ 'content_item_return_url' => 'http://example.com/', 'lti_message_type' => 'ContentItemSelectionRequest', ]), @@ -83,7 +83,7 @@ public function testAuthorizedItemSelectionRequestsRedirectToContentExplorer(): $platform = LtiPlatform::factory()->create(); $request = $this->oauthSigner->sign( - new Request('POST', 'https://hub.edlib.test/lti/1.1/select', [ + new Request('POST', 'https://hub-test.edlib.test/lti/1.1/select', [ 'content_item_return_url' => 'http://example.com/', 'lti_message_type' => 'ContentItemSelectionRequest', ]), @@ -92,13 +92,13 @@ public function testAuthorizedItemSelectionRequestsRedirectToContentExplorer(): $this->withCookie('_edlib_cookies', '1') ->post('/lti/1.1/select', $request->toArray()) - ->assertRedirect('https://hub.edlib.test/content'); + ->assertRedirect('https://hub-test.edlib.test/content'); } public function testUnauthorizedItemSelectionRequestsAreRejected(): void { $request = $this->oauthSigner->sign( - new Request('POST', 'https://hub.edlib.test/lti/1.1/select', [ + new Request('POST', 'https://hub-test.edlib.test/lti/1.1/select', [ 'content_item_return_url' => 'http://example.com/', 'lti_message_type' => 'ContentItemSelectionRequest', ]), @@ -115,7 +115,7 @@ public function testReportsErrorsToToolConsumer(): void $platform = LtiPlatform::factory()->create(); $request = $this->oauthSigner->sign( - new Request('POST', 'https://hub.edlib.test/lti/1.1/select', [ + new Request('POST', 'https://hub-test.edlib.test/lti/1.1/select', [ 'launch_presentation_return_url' => 'https://example.com/return', 'lti_message_type' => 'basic-lti-launch-request', ]),