Merge main onto develop

Merge main onto develop
This commit is contained in:
RamonRobben 2021-06-06 20:49:06 +02:00 committed by GitHub
commit ee13c115cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 417 additions and 585 deletions

38
.github/ISSUE_TEMPLATE/---bug-report.md vendored Normal file
View file

@ -0,0 +1,38 @@
---
name: "\U0001F41B Bug report"
about: Create a report to help us improve
title: ''
labels: bug
assignees: RamonRobben, AVMG20
---
**Describe the bug 🐛**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View file

@ -0,0 +1,31 @@
---
name: "\U0001F680 Feature request"
about: Suggest a feature or idea for this project
title: "[feature] "
labels: enhancement
assignees: RamonRobben, AVMG20
---
# 🚀 Feature Request
### Is your proposal related to a problem?
*Provide a clear and concise description of what the problem is.
For example, "I can't change x and it makes me have to do manual work"*
(Write your answer here.)
### Describe the solution you'd like
*Provide a clear and concise description of what you want to happen.
For Example, "Automate the changing of x so I don't have to do it manually"*
(Describe your proposed solution here.)
### Additional context
*Is there anything else you can add about the proposal?
You might want to link to related issues here, if you haven't already.*
(Write your answer here.)

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View file

@ -0,0 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: 🤷 Installation Help
url: https://discord.gg/4Y6HjD2uyU
about: Please visit our Discord for help with your installation.
- name: ❓ General Question
url: https://discord.gg/4Y6HjD2uyU
about: Please visit our Discord for general questions about the ControlPanel.

35
.github/workflows/run_tests.yml vendored Normal file
View file

@ -0,0 +1,35 @@
name: Laravel
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
laravel-tests:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.0'
- uses: actions/checkout@v2
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.dev', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/phpunit

37
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,37 @@
# Contributing
When contributing to this repository, please go through the open issues to see if you can contribute to something. If you want to contribute something that is not in the issues you can make an issue and wait for response from the dev team.
Please note we have a code of conduct, please follow it in all your interactions with the project.
## Pull request process
1. Give your PR a good descriptive title, so we can view immediately what the PR is about.
2. The dev team will look at your code and approve / merge when possible.
3. Make sure your PR follows our code of conduct and coding style.
## Code of Conduct
### Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
### Coding Style
We are following the PSR12 code standard for PHP.
### Our Standards
Examples of behavior that contributes to creating a positive environment include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

View file

@ -2,28 +2,19 @@
namespace App\Http\Controllers;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @param Request $request
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index(Request $request)
/** Show the application dashboard. */
public function index(Request $request): Renderable
{
//set cookie as extra layer of defense against users that make multiple accounts
setcookie('4b3403665fea6' , base64_encode(1) , time() + (20 * 365 * 24 * 60 * 60));

View file

@ -11,12 +11,8 @@ use Illuminate\Support\Facades\Auth;
class NotificationController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Factory|View
*/
public function index()
/** Display a listing of the resource. */
public function index(): View|Factory
{
$notifications = Auth::user()->notifications()->paginate();
@ -25,34 +21,8 @@ class NotificationController extends Controller
]);
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param string $id
* @return Factory|View
*/
public function show($id)
/** Display the specified resource. */
public function show(string $id): View|Factory
{
$notification = Auth::user()->notifications()->findOrFail($id);
@ -61,38 +31,4 @@ class NotificationController extends Controller
'notification' => $notification
]);
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}

View file

@ -14,12 +14,8 @@ use Illuminate\Support\Facades\Hash;
class ProfileController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Factory|View
*/
public function index()
/** Display a listing of the resource. */
public function index(): View|Factory
{
return view('profile.index')->with([
'user' => Auth::user(),
@ -28,57 +24,8 @@ class ProfileController extends Controller
]);
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return RedirectResponse
*/
public function update(Request $request, int $id)
/** Update the specified resource in storage. */
public function update(Request $request, int $id): RedirectResponse
{
//prevent other users from editing a user
if ($id != Auth::user()->id) dd(401);
@ -136,15 +83,4 @@ class ProfileController extends Controller
return redirect()->route('profile.index')->with('success' , 'profile updated');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}

View file

@ -22,26 +22,16 @@ use Illuminate\Support\Facades\Auth;
class ServerController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Factory|View
*/
public function index()
/** Display a listing of the resource. */
public function index(): View|Factory
{
return view('servers.index')->with([
'servers' => Auth::user()->Servers
]);
}
/**
* Show the form for creating a new resource.
*
* @return Factory|View|RedirectResponse
*/
public function create()
/** Show the form for creating a new resource. */
public function create(): View|Factory|RedirectResponse
{
//limit
if (Auth::user()->Servers->count() >= Auth::user()->server_limit) {
@ -63,13 +53,8 @@ class ServerController extends Controller
]);
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return RedirectResponse
*/
public function store(Request $request)
/** Store a newly created resource in storage. */
public function store(Request $request): RedirectResponse
{
$request->validate([
"name" => "required|max:191",
@ -89,7 +74,6 @@ class ServerController extends Controller
return redirect()->route('servers.index')->with('error', "You do not have the required amount of credits to create a new server!");
}
//create server
$egg = Egg::findOrFail($request->input('egg_id'));
$server = Auth::user()->servers()->create($request->all());
@ -110,11 +94,7 @@ class ServerController extends Controller
return redirect()->route('servers.index')->with('success', 'server created');
}
/**
* Quick Fix
* @param Server $server
* @return RedirectResponse
*/
/** Quick Fix */
private function serverCreationFailed(Server $server): RedirectResponse
{
$server->delete();
@ -123,51 +103,14 @@ class ServerController extends Controller
return redirect()->route('servers.index')->with('error', 'No allocations satisfying the requirements for automatic deployment were found.');
}
/**
* Display the specified resource.
*
* @param Server $server
* @return Response
*/
public function show(Server $server)
/** Remove the specified resource from storage. */
public function destroy(Server $server): RedirectResponse
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param Server $server
* @return Response
*/
public function edit(Server $server)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param Server $server
* @return Response
*/
public function update(Request $request, Server $server)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param Server $server
* @return RedirectResponse
* @throws Exception
*/
public function destroy(Server $server)
{
$server->delete();
return redirect()->route('servers.index')->with('success', 'server removed');
try {
$server->delete();
return redirect()->route('servers.index')->with('success', 'server removed');
} catch (\Exception $e) {
return redirect()->route('servers.index')->with('error', 'An exception has occurred while trying to remove a resource');
}
}
}

View file

@ -11,12 +11,8 @@ use Illuminate\Http\Response;
class StoreController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Application|Factory|View|Response
*/
public function index()
/** Display a listing of the resource. */
public function index(): View|Factory|Response|Application
{
$isPaypalSetup = false;
if (env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID')) $isPaypalSetup = true;
@ -26,70 +22,4 @@ class StoreController extends Controller
'isPaypalSetup' => $isPaypalSetup
]);
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}

View file

@ -8,7 +8,7 @@
],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"php": "^8.0",
"biscolab/laravel-recaptcha": "^5.0",
"doctrine/dbal": "^3.1",
"fideloper/proxy": "^4.4",
@ -30,7 +30,6 @@
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.2",
"mpociot/laravel-apidoc-generator": "^4.8",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},

440
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -5,11 +5,8 @@
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
<testsuite name="Tests">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">

View file

@ -1,69 +0,0 @@
<?php
namespace Tests\Feature;
use App\Models\DiscordUser;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ApiVerifyDiscordTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
*
* @return void
*/
public function test_verify_without_params()
{
$this->postJson('/api/verify')->assertStatus(422);
}
public function test_verify_with_invalid_user_id()
{
$this->postJson('/api/verify', [
'user_id' => rand(10000000, 100000000)
])->assertStatus(422)->assertJsonValidationErrors('user_id');
}
public function test_verify_with_valid_discord_user_id_but_with_invalid_user_id()
{
$discordUser = DiscordUser::factory()->create([
'user_id' => 9999999999999
]);
$this->postJson('/api/verify', [
'user_id' => $discordUser->id
])->assertStatus(422)->assertJsonValidationErrors('user_id');
}
public function test_verify_with_valid_discord_user_id_with_valid_user_id()
{
$discordUser = DiscordUser::factory()->create();
$this->postJson('/api/verify', [
'user_id' => $discordUser->id
])->assertStatus(200);
$this->assertEquals((250 + 375), User::find($discordUser->user->id)->credits);
$this->assertEquals(3, User::find($discordUser->user->id)->server_limit);
}
public function test_verify_second_time_should_not_work()
{
$discordUser = DiscordUser::factory()->create();
$this->postJson('/api/verify', [
'user_id' => $discordUser->id
])->assertStatus(200);
$this->postJson('/api/verify', [
'user_id' => $discordUser->id
])->assertStatus(422)->assertJsonValidationErrors('user_id');
$this->assertEquals((250 + 375), User::find($discordUser->user->id)->credits);
$this->assertEquals(3, User::find($discordUser->user->id)->server_limit);
}
}

View file

@ -0,0 +1,14 @@
<?php
namespace Tests\Unit;
use Tests\TestCase;
class exampleTest extends TestCase
{
public function test_example(): void
{
$response = $this->get('/');
$response->assertStatus(302);
}
}