-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UT] testing web access for IXP graphs
- Loading branch information
Showing
5 changed files
with
206 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Tests\Services\Grapher\Graph; | ||
|
||
use Tests\TestCase; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Foundation\Testing\WithoutMiddleware; | ||
|
||
use Config, D2EM; | ||
|
||
use Entities\User as UserEntity; | ||
|
||
abstract class Access extends TestCase | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?php | ||
|
||
namespace Tests\Services\Grapher\Graph; | ||
|
||
/* | ||
* Copyright (C) 2009-2018 Internet Neutral Exchange Association Company Limited By Guarantee. | ||
* All Rights Reserved. | ||
* | ||
* This file is part of IXP Manager. | ||
* | ||
* IXP Manager is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation, version v2.0 of the License. | ||
* | ||
* IXP Manager is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License v2.0 | ||
* along with IXP Manager. If not, see: | ||
* | ||
* http://www.gnu.org/licenses/gpl-2.0.html | ||
*/ | ||
|
||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Foundation\Testing\WithoutMiddleware; | ||
|
||
use Config, D2EM; | ||
|
||
use Entities\User as UserEntity; | ||
|
||
|
||
/** | ||
* Test access restrictions for IXP graphs | ||
* | ||
* Class IXPAccessTest | ||
* @package Tests\Services\Grapher\Graph | ||
*/ | ||
class IXPAccessTest extends Access | ||
{ | ||
/** | ||
* Test access restrictions for public web access | ||
* @return void | ||
*/ | ||
public function testWebPublicAccess() | ||
{ | ||
// this should be the default | ||
$response = $this->get('/statistics/ixp'); | ||
$response->assertStatus(200); | ||
|
||
// force the default | ||
Config::set( 'grapher.access.ixp', '0' ); | ||
$response = $this->get('/statistics/ixp'); | ||
$response->assertStatus(200); | ||
} | ||
|
||
/** | ||
* Test access restrictions for verious non-public access settings | ||
* @return void | ||
*/ | ||
public function testWebNonPublicAccess() | ||
{ | ||
Config::set( 'grapher.access.ixp', '1' ); | ||
$response = $this->get('/statistics/ixp'); | ||
$response->assertStatus(403); | ||
|
||
Config::set( 'grapher.access.ixp', '2' ); | ||
$response = $this->get('/statistics/ixp'); | ||
$response->assertStatus(403); | ||
|
||
Config::set( 'grapher.access.ixp', '3' ); | ||
$response = $this->get('/statistics/ixp'); | ||
$response->assertStatus(403); | ||
|
||
Config::set( 'grapher.access.ixp', 'blah' ); | ||
$response = $this->get('/statistics/ixp'); | ||
$response->assertStatus(403); | ||
|
||
Config::set( 'grapher.access.ixp', null ); | ||
$response = $this->get('/statistics/ixp'); | ||
$response->assertStatus(403); | ||
} | ||
|
||
/** | ||
* Test access restrictions requiring minimum logged in user of CustUser (privs=1) for web access | ||
* @return void | ||
*/ | ||
public function testWebCustUserAccess() | ||
{ | ||
Config::set( 'grapher.access.ixp', '1' ); | ||
$response = $this->get('/statistics/ixp'); | ||
$response->assertStatus(403); | ||
|
||
$response = $this->actingAs( $this->getCustUser() )->get('/statistics/ixp'); | ||
$response->assertStatus(200); | ||
|
||
$response = $this->actingAs( $this->getCustAdminUser() )->get('/statistics/ixp'); | ||
$response->assertStatus(200); | ||
|
||
$response = $this->actingAs( $this->getSuperUser() )->get('/statistics/ixp'); | ||
$response->assertStatus(200); | ||
} | ||
|
||
/** | ||
* Test access restrictions requiring minimum logged in user of CustAdmin (privs=2) for web access | ||
* @return void | ||
*/ | ||
public function testWebCustAdminAccess() | ||
{ | ||
Config::set( 'grapher.access.ixp', '2' ); | ||
$response = $this->get('/statistics/ixp'); | ||
$response->assertStatus(403); | ||
|
||
$response = $this->actingAs( $this->getCustUser() )->get('/statistics/ixp'); | ||
$response->assertStatus(403); | ||
|
||
$response = $this->actingAs( $this->getCustAdminUser() )->get('/statistics/ixp'); | ||
$response->assertStatus(200); | ||
|
||
$response = $this->actingAs( $this->getSuperUser() )->get('/statistics/ixp'); | ||
$response->assertStatus(200); | ||
} | ||
|
||
/** | ||
* Test access restrictions requiring logged in superuser (privs=3) for web access | ||
* @return void | ||
*/ | ||
public function testWebSuperuserAccess() | ||
{ | ||
Config::set( 'grapher.access.ixp', '3' ); | ||
$response = $this->get('/statistics/ixp'); | ||
$response->assertStatus(403); | ||
|
||
$response = $this->actingAs( $this->getCustUser() )->get('/statistics/ixp'); | ||
$response->assertStatus(403); | ||
|
||
$response = $this->actingAs( $this->getCustAdminUser() )->get('/statistics/ixp'); | ||
$response->assertStatus(403); | ||
|
||
$response = $this->actingAs( $this->getSuperUser() )->get('/statistics/ixp'); | ||
$response->assertStatus(200); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters