Skip to content

Commit

Permalink
Tests for new functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
joshcanhelp committed Aug 1, 2019
1 parent 0f4c2d1 commit 3bfea90
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/WP_Auth0_LoginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ public static function build_authorize_url( array $params = array() ) {
}

/**
* Get a value from query_vars or $_REQUEST global.
* Get a value from query_vars or request global.
*
* @param string $key - query var key to return.
*
Expand Down
45 changes: 45 additions & 0 deletions tests/testLoginManagerInitAuth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,51 @@ public function testThatErrorInUrlStopsCallback() {
$this->assertContains( '<a href="https://test.auth0.com/v2/logout?client_id=__test_client_id__', $output );
}

public function testThatQueryVarIsFound() {
self::auth0Ready();
set_query_var( 'auth0', 1 );

$output = '';
try {
$this->login->init_auth0();
} catch ( Exception $e ) {
$output = $e->getMessage();
}

// This error means that the callback was triggered, which is what we are testing for.
$this->assertContains( 'There was a problem with your log in: Invalid state', $output );
}

public function testThatGetVarIsFound() {
self::auth0Ready();
$_GET['auth0'] = 1;

$output = '';
try {
$this->login->init_auth0();
} catch ( Exception $e ) {
$output = $e->getMessage();
}

// This error means that the callback was triggered, which is what we are testing for.
$this->assertContains( 'There was a problem with your log in: Invalid state', $output );
}

public function testThatPostVarIsFound() {
self::auth0Ready();
$_POST['auth0'] = 1;

$output = '';
try {
$this->login->init_auth0();
} catch ( Exception $e ) {
$output = $e->getMessage();
}

// This error means that the callback was triggered, which is what we are testing for.
$this->assertContains( 'There was a problem with your log in: Invalid state', $output );
}

/**
* Test that an error in the URL parameter logs the current user out.
*/
Expand Down

0 comments on commit 3bfea90

Please sign in to comment.