mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-02-03 20:19:57 +01:00
Revert most of the previous changes as using bionic fixes travis
This commit is contained in:
parent
ef54b2371f
commit
34db59a991
10
.travis.yml
10
.travis.yml
@ -7,13 +7,13 @@ language: php
|
|||||||
|
|
||||||
php:
|
php:
|
||||||
- 7.4
|
- 7.4
|
||||||
# - 8.0
|
- 8.0
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# - mysql
|
- mysql
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
# - mysql -e 'CREATE DATABASE 2fauth_test;'
|
- mysql -e 'CREATE DATABASE 2fauth_test;'
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- travis_retry composer self-update
|
- travis_retry composer self-update
|
||||||
@ -22,10 +22,8 @@ before_script:
|
|||||||
# will use .env.testing by default
|
# will use .env.testing by default
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# - DATABASE=mysql vendor/bin/phpunit -c phpunit-mysql.xml
|
- DATABASE=mysql vendor/bin/phpunit -c phpunit-mysql.xml
|
||||||
- cp .env.travis .env
|
|
||||||
- php artisan config:clear
|
- php artisan config:clear
|
||||||
- php artisan key:generate
|
|
||||||
- DATABASE=sqlite vendor/bin/phpunit -c phpunit.xml --coverage-clover=coverage.xml
|
- DATABASE=sqlite vendor/bin/phpunit -c phpunit.xml --coverage-clover=coverage.xml
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
|
@ -19,6 +19,7 @@ public function up()
|
|||||||
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
$table->text('account')->change();
|
$table->text('account')->change();
|
||||||
|
$table->text('uri')->change();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class AlterEncryptedColumnsToTextForSqliteBis extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$driver = Schema::connection($this->getConnection())->getConnection()->getDriverName();
|
|
||||||
|
|
||||||
if ('sqlite' === $driver) {
|
|
||||||
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
|
||||||
$table->text('uri')->change();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
|
||||||
//
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,17 +16,44 @@ class SplitTwofaccountsUriInMultipleColumns extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
// as SQLITE disallow to add a not nullable column without default
|
|
||||||
// value when altering a table we add all columns as nullable and
|
|
||||||
// change them right after to not nullable column
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
$table->string('otp_type', 10)->nullable();
|
$table->string('otp_type', 10);
|
||||||
$table->text('secret')->nullable();
|
$table->text('secret');
|
||||||
$table->string('algorithm', 20)->nullable();
|
$table->string('algorithm', 20);
|
||||||
$table->unsignedSmallInteger('digits')->nullable();
|
$table->unsignedSmallInteger('digits');
|
||||||
$table->unsignedInteger('period')->nullable();
|
$table->unsignedInteger('period')->nullable();
|
||||||
$table->unsignedBigInteger('counter')->nullable();
|
$table->unsignedBigInteger('counter')->nullable();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('uri', 'legacy_uri');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$twofaccounts = DB::table('twofaccounts')->select('id', 'legacy_uri')->get();
|
||||||
|
$settingService = resolve('App\Services\SettingService');
|
||||||
|
|
||||||
|
foreach ($twofaccounts as $twofaccount) {
|
||||||
|
try {
|
||||||
|
$legacy_uri = $settingService->get('useEncryption') ? Crypt::decryptString($twofaccount->legacy_uri) : $twofaccount->legacy_uri;
|
||||||
|
$token = \OTPHP\Factory::loadFromProvisioningUri($legacy_uri);
|
||||||
|
|
||||||
|
$affected = DB::table('twofaccounts')
|
||||||
|
->where('id', $twofaccount->id)
|
||||||
|
->update([
|
||||||
|
'otp_type' => get_class($token) === 'OTPHP\TOTP' ? 'totp' : 'hotp',
|
||||||
|
'secret' => $settingService->get('useEncryption') ? Crypt::encryptString($token->getSecret()) : $token->getSecret(),
|
||||||
|
'algorithm' => $token->getDigest(),
|
||||||
|
'digits' => $token->getDigits(),
|
||||||
|
'period' => $token->hasParameter('period') ? $token->getParameter('period') : null,
|
||||||
|
'counter' => $token->hasParameter('counter') ? $token->getParameter('counter') : null
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
catch(Exception $ex)
|
||||||
|
{
|
||||||
|
Log::error($ex->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,5 +86,9 @@ public function down()
|
|||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
$table->dropColumn('counter');
|
$table->dropColumn('counter');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('legacy_uri', 'uri');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class RenameUriToLegacyUri extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
|
||||||
$table->renameColumn('uri', 'legacy_uri');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
|
||||||
$table->renameColumn('legacy_uri', 'uri');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\Crypt;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class ChangeNullableInTwofaccountsTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
|
||||||
$table->text('account')->nullable(false)->change();
|
|
||||||
$table->string('service')->nullable()->change();
|
|
||||||
$table->string('otp_type', 10)->nullable(false)->change();
|
|
||||||
$table->text('secret')->nullable(false)->change();
|
|
||||||
$table->string('algorithm', 20)->nullable(false)->change();
|
|
||||||
$table->unsignedSmallInteger('digits')->nullable(false)->change();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$twofaccounts = DB::table('twofaccounts')->select('id', 'legacy_uri')->get();
|
|
||||||
$settingService = resolve('App\Services\SettingService');
|
|
||||||
|
|
||||||
foreach ($twofaccounts as $twofaccount) {
|
|
||||||
try {
|
|
||||||
$legacy_uri = $settingService->get('useEncryption') ? Crypt::decryptString($twofaccount->legacy_uri) : $twofaccount->legacy_uri;
|
|
||||||
$token = \OTPHP\Factory::loadFromProvisioningUri($legacy_uri);
|
|
||||||
|
|
||||||
$affected = DB::table('twofaccounts')
|
|
||||||
->where('id', $twofaccount->id)
|
|
||||||
->update([
|
|
||||||
'otp_type' => get_class($token) === 'OTPHP\TOTP' ? 'totp' : 'hotp',
|
|
||||||
'secret' => $settingService->get('useEncryption') ? Crypt::encryptString($token->getSecret()) : $token->getSecret(),
|
|
||||||
'algorithm' => $token->getDigest(),
|
|
||||||
'digits' => $token->getDigits(),
|
|
||||||
'period' => $token->hasParameter('period') ? $token->getParameter('period') : null,
|
|
||||||
'counter' => $token->hasParameter('counter') ? $token->getParameter('counter') : null
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
catch(Exception $ex)
|
|
||||||
{
|
|
||||||
Log::error($ex->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
backupGlobals="false"
|
|
||||||
backupStaticAttributes="false"
|
|
||||||
bootstrap="vendor/autoload.php"
|
|
||||||
colors="true"
|
|
||||||
convertErrorsToExceptions="true"
|
|
||||||
convertNoticesToExceptions="true"
|
|
||||||
convertWarningsToExceptions="true"
|
|
||||||
processIsolation="false"
|
|
||||||
stopOnFailure="false"
|
|
||||||
stopOnError="false"
|
|
||||||
beStrictAboutTestsThatDoNotTestAnything="false"
|
|
||||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
|
||||||
<coverage processUncoveredFiles="true">
|
|
||||||
<include>
|
|
||||||
<directory suffix=".php">./app</directory>
|
|
||||||
</include>
|
|
||||||
</coverage>
|
|
||||||
<testsuites>
|
|
||||||
<testsuite name="Unit">
|
|
||||||
<directory suffix="Test.php">./tests/Unit</directory>
|
|
||||||
</testsuite>
|
|
||||||
<testsuite name="Feature">
|
|
||||||
<directory suffix="Test.php">./tests/Feature</directory>
|
|
||||||
</testsuite>
|
|
||||||
<testsuite name="Api.v1">
|
|
||||||
<directory suffix="Test.php">./tests/Api/v1</directory>
|
|
||||||
</testsuite>
|
|
||||||
</testsuites>
|
|
||||||
<php>
|
|
||||||
<env name="APP_ENV" value="testing"/>
|
|
||||||
<!-- following values override .env.testing vars -->
|
|
||||||
</php>
|
|
||||||
</phpunit>
|
|
Loading…
Reference in New Issue
Block a user