diff --git a/.env.dusk.local b/.env.dusk.local index c996df74a0a9..cef7d47e8ff2 100644 --- a/.env.dusk.local +++ b/.env.dusk.local @@ -1,7 +1,7 @@ APP_ENV=local APP_DEBUG=true APP_LOCALE=en -APP_URL=http://ninja.test:8000 +APP_URL=http://127.0.0.1:8000 APP_KEY=s7epnjtomsdond5zgfqgaqmwhhcjct02 APP_CIPHER=AES-256-CBC REQUIRE_HTTPS=false @@ -13,8 +13,9 @@ DB_HOST=localhost DB_USERNAME=ninja DB_PASSWORD=ninja -DB_DATABASE1=ninja1 -DB_DATABASE2=ninja2 +DB_CONNECTION=db-ninja-01 +DB_DATABASE1=db-ninja-01 +DB_DATABASE2=db-ninja-02 MAIL_DRIVER=smtp MAIL_PORT=587 MAIL_ENCRYPTION=tls diff --git a/.env.example b/.env.example index e000111fcebd..79f2bf95084d 100644 --- a/.env.example +++ b/.env.example @@ -1,19 +1,19 @@ -APP_NAME=Laravel +APP_NAME="Invoice Ninja" APP_ENV=local APP_KEY= APP_DEBUG=true + APP_URL=http://localhost -LOG_CHANNEL=stack - -DB_CONNECTION=mysql -DB_HOST=127.0.0.1 -DB_PORT=3306 -DB_DATABASE=homestead -DB_USERNAME=homestead -DB_PASSWORD=secret +DB_CONNECTION=db-ninja-01 +DB_HOST1=127.0.0.1 +DB_PORT1=3306 +DB_DATABASE1=homestead +DB_USERNAME1=homestead +DB_PASSWORD1=secret BROADCAST_DRIVER=log +LOG_CHANNEL=stack CACHE_DRIVER=file QUEUE_CONNECTION=sync SESSION_DRIVER=file diff --git a/app/Jobs/Company/CreateCompany.php b/app/Jobs/Company/CreateCompany.php index 88cc75d9df92..275d249be47b 100644 --- a/app/Jobs/Company/CreateCompany.php +++ b/app/Jobs/Company/CreateCompany.php @@ -5,6 +5,7 @@ namespace App\Jobs\Company; use App\Events\Company\CompanyCreated; use App\Events\UserSignedUp; use App\Jobs\Account\CreateAccount; +use App\Utils\Traits\MakesHash; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Http\Request; use App\Models\Account; @@ -15,7 +16,7 @@ use Illuminate\Support\Facades\Hash; class CreateCompany { - + use MakesHash; use Dispatchable; protected $request; @@ -45,7 +46,7 @@ class CreateCompany $company = new Company(); $company->name = $this->request->first_name . ' ' . $this->request->last_name; $company->account_id = $this->account->id; - $company->company_key = strtolower(str_random(RANDOM_KEY_LENGTH)); + $company->company_key = $this->createHash(); $company->ip = $this->request->ip(); $company->save(); diff --git a/app/Jobs/User/CreateUser.php b/app/Jobs/User/CreateUser.php index 749fc8568bc1..130ee65e48dd 100644 --- a/app/Jobs/User/CreateUser.php +++ b/app/Jobs/User/CreateUser.php @@ -4,6 +4,7 @@ namespace App\Jobs\User; use App\Models\User; use App\Models\UserCompany; +use App\Utils\Traits\MakesHash; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Http\Request; use App\Models\Account; @@ -11,7 +12,7 @@ use Illuminate\Support\Facades\Hash; class CreateUser { - + use MakesHash; use Dispatchable; protected $request; @@ -45,7 +46,7 @@ class CreateUser $user->account_id = $this->account->id; $user->password = bcrypt($this->request->input('password')); $user->accepted_terms_version = config('ninja.terms_version'); - $user->confirmation_code = strtolower(str_random(RANDOM_KEY_LENGTH)); + $user->confirmation_code = $this->createDbHash(config('database.default')); $user->db = config('database.default'); $user->fill($this->request->all()); $user->save(); diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php deleted file mode 100644 index bf7ef56242db..000000000000 --- a/app/Providers/TelescopeServiceProvider.php +++ /dev/null @@ -1,51 +0,0 @@ -app->environment() == 'local') { - return true; - } - - return $entry->isReportableException() || - $entry->isFailedJob() || - $entry->isScheduledTask() || - $entry->hasMonitoredTag(); - }); - } - - /** - * Register the Telescope gate. - * - * This gate determines who can access Telescope in non-local environments. - * - * @return void - */ - protected function gate() - { - Gate::define('viewTelescope', function ($user) { - return in_array($user->email, [ - config('ninja.contact.email'), - 'turbo124@gmail.com' - ]); - }); - } -} diff --git a/app/Utils/Traits/MakesHash.php b/app/Utils/Traits/MakesHash.php new file mode 100644 index 000000000000..5e4f1365fdce --- /dev/null +++ b/app/Utils/Traits/MakesHash.php @@ -0,0 +1,43 @@ +encode( str_replace( MultiDB::DB_PREFIX, "", $db ) ); + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index 0e02324cbc95..18a45f065561 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,6 @@ "laracasts/presenter": "^0.2.1", "laravel/framework": "5.7.*", "laravel/socialite": "^3.1", - "laravel/telescope": "^0.1.1", "laravel/tinker": "^1.0", "nwidart/laravel-modules": "^4.0", "predis/predis": "^1.1", diff --git a/composer.lock b/composer.lock index 25f90aa1baa5..3e16ef0628d8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8f50fadc77133971d60134045427a805", + "content-hash": "f070f7f4ccfe346840e4dfd0e39650a5", "packages": [ { "name": "asgrim/ofxparser", @@ -1066,68 +1066,6 @@ ], "time": "2018-10-18T03:39:04+00:00" }, - { - "name": "laravel/telescope", - "version": "v0.1.2", - "source": { - "type": "git", - "url": "https://github.com/laravel/telescope.git", - "reference": "253dde9a80d50e90c7f9d4d6621151acf556d1a1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/telescope/zipball/253dde9a80d50e90c7f9d4d6621151acf556d1a1", - "reference": "253dde9a80d50e90c7f9d4d6621151acf556d1a1", - "shasum": "" - }, - "require": { - "ext-json": "*", - "laravel/framework": "~5.7.7", - "moontoast/math": "^1.1", - "php": "^7.1.3", - "symfony/var-dumper": "^4.1" - }, - "require-dev": { - "nunomaduro/larastan": "^0.3.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - }, - "laravel": { - "providers": [ - "Laravel\\Telescope\\TelescopeServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Laravel\\Telescope\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - }, - { - "name": "Mohamed Said", - "email": "mohamed@laravel.com" - } - ], - "description": "An elegant debug assistant for the Laravel framework.", - "keywords": [ - "debugging", - "laravel", - "monitoring" - ], - "time": "2018-10-24T11:28:33+00:00" - }, { "name": "laravel/tinker", "version": "v1.0.8", @@ -1416,55 +1354,6 @@ ], "time": "2017-06-19T01:22:40+00:00" }, - { - "name": "moontoast/math", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/ramsey/moontoast-math.git", - "reference": "c2792a25df5cad4ff3d760dd37078fc5b6fccc79" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ramsey/moontoast-math/zipball/c2792a25df5cad4ff3d760dd37078fc5b6fccc79", - "reference": "c2792a25df5cad4ff3d760dd37078fc5b6fccc79", - "shasum": "" - }, - "require": { - "ext-bcmath": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "jakub-onderka/php-parallel-lint": "^0.9.0", - "phpunit/phpunit": "^4.7|>=5.0 <5.4", - "satooshi/php-coveralls": "^0.6.1", - "squizlabs/php_codesniffer": "^2.3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Moontoast\\Math\\": "src/Moontoast/Math/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Ben Ramsey", - "email": "ben@benramsey.com", - "homepage": "https://benramsey.com" - } - ], - "description": "A mathematics library, providing functionality for large numbers", - "homepage": "https://github.com/ramsey/moontoast-math", - "keywords": [ - "bcmath", - "math" - ], - "time": "2017-02-16T16:54:46+00:00" - }, { "name": "nesbot/carbon", "version": "1.34.0", diff --git a/config/app.php b/config/app.php index 264e368d5a73..d5d66c7021b2 100644 --- a/config/app.php +++ b/config/app.php @@ -177,7 +177,6 @@ return [ App\Providers\AuthServiceProvider::class, // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, - App\Providers\TelescopeServiceProvider::class, App\Providers\RouteServiceProvider::class, ], diff --git a/config/database.php b/config/database.php index e307f79d4e0a..9790da24c21e 100644 --- a/config/database.php +++ b/config/database.php @@ -39,22 +39,6 @@ return [ 'prefix' => '', ], - 'mysql' => [ - 'driver' => 'mysql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '3306'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'unix_socket' => env('DB_SOCKET', ''), - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - 'prefix_indexes' => true, - 'strict' => env('DB_STRICT', false), - 'engine' => 'InnoDB', - ], - 'pgsql' => [ 'driver' => 'pgsql', 'host' => env('DB_HOST', '127.0.0.1'), diff --git a/tests/Browser/CreateAccountTest.php b/tests/Browser/CreateAccountTest.php index 7905f7cdb6e9..8532bc7a48fc 100644 --- a/tests/Browser/CreateAccountTest.php +++ b/tests/Browser/CreateAccountTest.php @@ -3,10 +3,10 @@ namespace Tests\Browser; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\DB; use Tests\DuskTestCase; use Illuminate\Foundation\Testing\WithFaker; -use Illuminate\Foundation\Testing\WithoutMiddleware; - +use Laravel\Dusk\Browser; class CreateAccountTest extends DuskTestCase { @@ -27,30 +27,21 @@ class CreateAccountTest extends DuskTestCase */ public function testCreateAValidUser() { - /* - $response = $this->post('/signup', [ - 'first_name' => $this->faker->firstName(), - 'last_name' => $this->faker->lastName(), - 'terms_of_service' => 1, - 'privacy_policy' => 1, - 'email' => config('ninja.testvars.username'), - 'password' => config('ninja.testvars.password') - ]); + DB::beginTransaction(); + $this->browse(function (Browser $browser) { + $browser->visit('/signup') + ->type('first_name',$this->faker->firstName()) + ->type('last_name', $this->faker->lastName()) + ->type('email', $this->faker->email()) + ->type('password', $this->faker->password(7)) + ->check('terms_of_service') + ->check('privacy_policy') + ->press(trans('texts.create_account')) + ->assertPathIs('/dashboard'); + }); - $response->assertSuccessful(); - */ - - $this->visit('/signup') - ->type($this->faker->firstName(), 'first_name') - ->type($this->faker->lastName(), 'last_name') - ->type($this->faker->email(), 'email') - ->type($this->faker->password(7), 'password') - ->check('terms_of_service') - ->check('terms_of_service') - ->press(trans('texts.create_account')) - ->seePageIs('/dashboard'); - + DB::rollback(); } } diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php index 3827756b4af4..9c21a4da7977 100644 --- a/tests/Browser/ExampleTest.php +++ b/tests/Browser/ExampleTest.php @@ -17,7 +17,7 @@ class ExampleTest extends DuskTestCase { $this->browse(function (Browser $browser) { $browser->visit('/') - ->assertSee('Laravel'); + ->assertSee('Account'); }); } } diff --git a/tests/Feature/LoginTest.php b/tests/Feature/LoginTest.php index 4b0cd61e61e3..e4c0a0c5c3ea 100644 --- a/tests/Feature/LoginTest.php +++ b/tests/Feature/LoginTest.php @@ -5,6 +5,7 @@ namespace Tests\Feature; use App\Models\Account; use App\Models\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\Session; use Tests\TestCase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -14,6 +15,11 @@ class LoginTest extends TestCase use DatabaseTransactions; + public function setUp() + { + parent::setUp(); + } + public function testLoginFormDisplayed() { $response = $this->get('/login');