Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • sebastian/MetaGer
  • cpietsch/MetaGer
  • kossow/MetaGer
  • jens/MetaGer
  • open-source/MetaGer
5 results
Show changes
Commits on Source (29)
Showing
with 633 additions and 106 deletions
......@@ -21,3 +21,4 @@ npm-debug.log
/.project
composer.lock
local.log
\ No newline at end of file
......@@ -215,5 +215,4 @@ integrationtest:
- sed -i "s#^APP_URL=.*#APP_URL=$URL#g" .env
- sed -i "s#^BRANCH_NAME=.*#BRANCH_NAME=$CI_COMMIT_REF_NAME#g" .env
- sed -i "s#^COMMIT_NAME=.*#COMMIT_NAME=$CI_COMMIT_REF_SLUG#g" .env
- ./vendor/phpunit/phpunit/phpunit
- php artisan dusk
\ No newline at end of file
<?php
namespace App;
use BrowserStack\Local;
use Facebook\WebDriver\Remote\RemoteWebDriver;
class Browserstack
{
private $webdriver, $bs_local = null;
private $LOCALCAPABILITIES = array();
private $CAPABILITIES = array();
public function __construct()
{
$this->setCapabilities();
$caps = null;
if ($this->isLocal()) {
$caps = $this->LOCALCAPABILITIES;
$this->bs_local = new Local();
$bs_local_args = array("key" => env("WEBDRIVER_KEY", ""));
$this->bs_local->start($bs_local_args);
} else {
$caps = $this->CAPABILITIES;
}
$this->webdriver = RemoteWebDriver::create(
getenv("WEBDRIVER_URL"),
$caps
);
}
private function setCapabilities()
{
$this->LOCALCAPABILITIES = array(
"os" => "Windows",
"os_version" => "10",
"browser" => "Firefox",
"browser_version" => "79.0 beta",
"resolution" => "1920x1080",
"project" => env("PROJECT_NAME", "Not Set"),
"build" => env("BRANCH_NAME", "Not Set"),
"name" => env("COMMIT_NAME", "Not Set"),
"browserstack.local" => "true",
"browserstack.console" => "verbose",
"browserstack.networkLogs" => "true",
"browserstack.timezone" => "Europe/Berlin",
"browserstack.selenium_version" => "3.5.2",
);
$this->CAPABILITIES = array(
"os" => "Windows",
"os_version" => "10",
"browser" => "Firefox",
"browser_version" => "79.0 beta",
"resolution" => "1920x1080",
"project" => env("PROJECT_NAME", "Not Set"),
"build" => env("BRANCH_NAME", "Not Set"),
"name" => env("COMMIT_NAME", "Not Set"),
"browserstack.local" => "false",
"browserstack.console" => "verbose",
"browserstack.networkLogs" => "true",
"browserstack.timezone" => "Europe/Berlin",
"browserstack.selenium_version" => "3.5.2",
);
}
public function getWebdriver()
{
return $this->webdriver;
}
public function shutdown()
{
$this->webdriver->quit();
if ($this->bs_local != null) {
$this->bs_local->stop();
}
}
private function isLocal()
{
return env("APP_URL", "") === "http://nginx";
}
}
......@@ -39,6 +39,7 @@ class HumanVerification extends Controller
$key = strtolower($key);
if (!$hasher->check($key, $lockedKey)) {
sleep(\random_int(1, 8));
$captcha = Captcha::create("default", true);
$user["lockedKey"] = $captcha["key"];
HumanVerification::saveUser($user);
......@@ -65,6 +66,7 @@ class HumanVerification extends Controller
}
}
}
sleep(\random_int(1, 8));
$captcha = Captcha::create("default", true);
$user["lockedKey"] = $captcha["key"];
HumanVerification::saveUser($user);
......@@ -105,7 +107,7 @@ class HumanVerification extends Controller
private static function saveUser($user)
{
$userList = Cache::get(HumanVerification::PREFIX . "." . $user["id"], []);
if ($user["whitelist"]) {
$user["expiration"] = now()->addWeeks(2);
} else {
......@@ -204,13 +206,16 @@ class HumanVerification extends Controller
return true;
} else if (\preg_match("/^\s*site:\"linkedin\.com[^\"]*\"\s+/si", $eingabe)) {
return true;
} else if (\preg_match("/^\d+.(php|asp)\s+\?.*=.*/si", $eingabe)) {
return true;
}
return $possibleSpammer;
}
public function botOverview(Request $request){
public function botOverview(Request $request)
{
$id = "";
$uid = "";
$ip = $request->ip();
......@@ -232,7 +237,8 @@ class HumanVerification extends Controller
->with('user', $user);
}
public function botOverviewChange(Request $request) {
public function botOverviewChange(Request $request)
{
$id = "";
$uid = "";
$ip = $request->ip();
......@@ -247,11 +253,11 @@ class HumanVerification extends Controller
$userList = Cache::get(HumanVerification::PREFIX . "." . $id);
$user = $userList[$uid];
if($request->filled("locked")){
if ($request->filled("locked")) {
$user["locked"] = boolval($request->input('locked'));
}elseif($request->filled("whitelist")) {
} elseif ($request->filled("whitelist")) {
$user["whitelist"] = boolval($request->input('whitelist'));
}elseif($request->filled("unusedResultPages")) {
} elseif ($request->filled("unusedResultPages")) {
$user["unusedResultPages"] = intval($request->input('unusedResultPages'));
}
......
......@@ -80,7 +80,7 @@ class HumanVerification
}
}
}
# A lot of automated requests are from websites that redirect users to our result page.
# We will detect those requests and put a captcha
$referer = URL::previous();
......@@ -98,9 +98,10 @@ class HumanVerification
if ((!$alone && $sum >= 50 && !$user["whitelist"]) || $refererLock) {
$user["locked"] = true;
}
# If the user is locked we will force a Captcha validation
if ($user["locked"]) {
sleep(\random_int(1, 8));
$captcha = Captcha::create("default", true);
$user["lockedKey"] = $captcha["key"];
\App\PrometheusExporter::CaptchaShown();
......
<?php
namespace App\Traits;
use BrowserStack\Local;
use Facebook\WebDriver\Remote\RemoteWebDriver;
/**
* Run BrowserStack from your tests.
*/
trait SupportsBrowserStack
{
protected static $bs_local;
/**
* Create the BrowserStack WebDriver instance.
*/
public function createBrowserStackDriver(array $config = null): RemoteWebDriver
{
if ($config["capabilities"]["browserstack.local"] === "true") {
$this->bs_local = new Local();
$bs_local_args = [
"key" => $config["key"],
];
$this->bs_local->start($bs_local_args);
}
return RemoteWebDriver::create(
"https://$config[username]:$config[key]@hub-cloud.browserstack.com/wd/hub",
$config["capabilities"]
);
}
/**
* @afterClass
*/
public static function shutdown()
{
if (static::$bs_local && static::$bs_local->isRunning()) {
static::$bs_local->stop();
}
}
}
......@@ -75,4 +75,4 @@ services:
working_dir: /html
volumes:
- .:/html
command: "./vendor/phpunit/phpunit/phpunit"
command: "php artisan dusk"
/bin/sh: 1: ps: not found
/bin/sh: 1: ps: not found
Thu Jul 09 2020 11:17:18 GMT+0000 (UTC) -- [INFO] Started the BrowserStack Binary server on 45691, PID: 22
Thu Jul 09 2020 11:17:19 GMT+0000 (UTC) -- [SUCCESS] You can now access your local server(s) in our remote browser
Thu Jul 09 2020 11:17:19 GMT+0000 (UTC) -- Press Ctrl-C to exit
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class About extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/about';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Was MetaGer auszeichnet")
->assertTitle("Über Uns - MetaGer")
->switchLanguage("English")
->waitForText("MetaGer - Characteristic qualities")
->assertTitle("About Us - MetaGer")
->switchLanguage("Español")
->waitForText("Was MetaGer auszeichnet")
->assertTitle("Sobre nosotros - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class App extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/app';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Diese App bringt die volle Power unserer Suchmaschine auf ihr Smartphone.")
->assertTitle("Apps - MetaGer")
->switchLanguage("English")
->waitForText("This App brings the full Metager power to your smartphone.")
->assertTitle("Apps - MetaGer")
->switchLanguage("Español")
->waitForText("Diese App bringt die volle Power unserer Suchmaschine auf ihr Smartphone.")
->assertTitle("Aplicaciones - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class Datenschutz extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/datenschutz';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Datenschutz bei MetaGer/SUMA-EV")
->assertTitle("Datenschutz und Privatsphäre - MetaGer")
->switchLanguage("English")
->waitForText("Data protection at MetaGer/SUMA-EV")
->assertTitle("Privacy - MetaGer")
->switchLanguage("Español")
->waitForText("Data protection at MetaGer/SUMA-EV")
->assertTitle("Protección de datos y privacidad - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class Hilfe extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/hilfe';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("MetaGer - Hilfe")
->assertTitle("Hilfe - MetaGer")
->switchLanguage("English")
->waitForText("MetaGer Help")
->assertTitle("Help - MetaGer")
->switchLanguage("Español")
->waitForText("MetaGer - Hilfe")
->assertTitle("Ayuda - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class HomePage extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/';
}
/**
* Assert that the browser is on the page.
*
* @param \Laravel\Dusk\Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
# German
$browser->assertPathIs($this->url())
->waitForText("Garantierte Privatsphäre", 1)
->assertTitle('MetaGer - Mehr als eine Suchmaschine')
->assertSee("Vielfältig & Frei")
->assertSee("100% Ökostrom")
->assertSee("Gemeinnütziger Verein")
->switchLanguage("English")
->waitForText("Guaranteed Privacy", 1)
->assertTitle('MetaGer: Privacy Protected Search & Find')
->assertSee("Diverse & free")
->assertSee("100 % renewable energy")
->assertSee("Nonprofit organization")
->switchLanguage("Español")
->waitForText("Privacidad garantizada", 1)
->assertTitle('MetaGer: Buscar & encontrar seguro, proteger la privacidad')
->assertSee("Diversa y libre")
->assertSee("Energía 100% renovable")
->assertSee("Organización sin ánimo de lucro")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@sidebarToggle' => 'label.sidebar-opener[for=sidebarToggle]',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class Impress extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/impressum';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Haftungshinweis:")
->assertTitle("Impressum - MetaGer")
->switchLanguage("English")
->waitForText("Liability Note:")
->assertTitle("Site Notice - MetaGer")
->switchLanguage("Español")
->waitForText("Exención de responsabilidad")
->assertTitle("Aviso legal - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class Kontakt extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/kontakt';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Sicheres Kontaktformular")
->assertTitle("Kontakt - MetaGer")
->switchLanguage("English")
->waitForText("Secure Contact Form")
->assertTitle("Contact - MetaGer")
->switchLanguage("Español")
->waitForText("Formulario de contacto seguro")
->assertTitle("Contacto - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
use Laravel\Dusk\Page as BasePage;
abstract class Page extends BasePage
{
/**
* Get the global element shortcuts for the site.
*
* @return array
*/
public static function siteElements()
{
return [
'@sidebarToggle' => 'label.sidebar-opener[for=sidebarToggle]',
'@languageDropdown' => '#navigationSprache',
];
}
public function switchLanguage(Browser $browser, $language)
{
$browser->waitFor("@sidebarToggle")
->click("@sidebarToggle")
->click("@languageDropdown")
->clickLink($language);
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class Plugin extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/plugin';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("MetaGer zum Firefox hinzufügen")
->assertTitle("Plugin - MetaGer")
->switchLanguage("English")
->waitForText("Add MetaGer to your Firefox")
->assertTitle("Plugin - MetaGer")
->switchLanguage("Español")
->waitForText("Añadir MetaGer a Firefox")
->assertTitle("Plugin - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class SitesearchWidget extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/sitesearch/';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Hier finden Sie ein Metager-Widget für Ihre Webseite.")
->assertTitle("Sitesearch-Widget - MetaGer")
->type("site", "https://metager.de")
->press("Generieren")
->waitForLocation("/sitesearch")
->waitForText("Hier finden Sie ein Metager-Widget für Ihre Webseite.")
->assertTitle("Sitesearch-Widget - MetaGer")
->visit($this->url())
->switchLanguage("English")
->waitForText("Here you find a Metager-Widget for your website.")
->assertTitle("Sitesearch-Widget - MetaGer")
->type("site", "https://metager.de")
->press("Generate");
$location = "/en/sitesearch";
if (env("APP_ENV", "") === "production") {
$location = "/sitesearch";
}
$browser->waitForLocation($location)
->waitForText("Here you find a Metager-Widget for your website.")
->assertTitle("Sitesearch-Widget - MetaGer")
->visit($this->url())
->switchLanguage("Español")
->waitForText("Aquí encuentra el Metger-Widget para su sitio web")
->assertTitle("Widget para búsquedas dentro de tu página - MetaGer")
->type("site", "https://metager.de")
->press("Generar");
$location = "/es/sitesearch";
if (env("APP_ENV", "") === "production") {
$location = "/sitesearch";
}
$browser->waitForLocation($location)
->waitForText("Aquí encuentra el Metger-Widget para su sitio web")
->assertTitle("Widget para búsquedas dentro de tu página - MetaGer")
->visit($this->url())
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class Spende extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/spende';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->assertPathIs($this->url())
->waitForText("Ihre Spende für SUMA-EV und MetaGer")
->assertTitle("Spenden - MetaGer")
->switchLanguage("English")
->waitForText("Your Donation for MetaGer to SUMA-EV")
->assertTitle("Donation - MetaGer")
->switchLanguage("Español")
->waitForText("Su donación para SUME-EV y MetaGer")
->assertTitle("Donaciones - MetaGer")
->switchLanguage("Deutsch");
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}