-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from microsoft/dev
Release 1.1.0
- Loading branch information
Showing
12 changed files
with
222 additions
and
32 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
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 |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
|
||
class Constants | ||
{ | ||
public const VERSION = "1.0.2"; | ||
public const VERSION = "1.1.0"; | ||
} |
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,61 @@ | ||
<?php | ||
|
||
namespace Microsoft\Kiota\Authentication\Test\Cache; | ||
|
||
use League\OAuth2\Client\Token\AccessToken; | ||
use Microsoft\Kiota\Authentication\Cache\InMemoryAccessTokenCache; | ||
use Microsoft\Kiota\Authentication\Oauth\ClientCredentialContext; | ||
use Microsoft\Kiota\Authentication\Oauth\TokenRequestContext; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class InMemoryAccessTokenCacheTest extends TestCase | ||
{ | ||
private ClientCredentialContext $testTokenRequestContext; | ||
private string $testTokenRequestContextCacheKey = "tenantId-clientId"; | ||
|
||
public function setUp(): void { | ||
$this->testTokenRequestContext = new ClientCredentialContext("tenantId", "clientId", "clientSecret"); | ||
} | ||
|
||
public function testConstructorWorksWithEmptyArguments() { | ||
$cache = new InMemoryAccessTokenCache(); | ||
$this->assertInstanceOf(InMemoryAccessTokenCache::class, $cache); | ||
} | ||
|
||
public function testConstructorInitialisesCache() { | ||
$cache = new InMemoryAccessTokenCache($this->testTokenRequestContext, $this->createMock(AccessToken::class)); | ||
$this->assertInstanceOf(AccessToken::class, $cache->getTokenWithContext($this->testTokenRequestContext)); | ||
} | ||
|
||
public function tesWithTokenInitialisesCache() { | ||
$cache = new InMemoryAccessTokenCache(); | ||
$cache->withToken($this->testTokenRequestContext, $this->createMock(AccessToken::class)); | ||
$this->assertInstanceOf(AccessToken::class, $cache->getTokenWithContext($this->testTokenRequestContext)); | ||
} | ||
|
||
public function testWithTokenThrowsExceptionIfCacheKeyCannotBeInitialised() { | ||
$tokenRequestContext = $this->createMock(TokenRequestContext::class); | ||
$tokenRequestContext->method('getCacheKey')->willReturn(null); | ||
$cache = new InMemoryAccessTokenCache(); | ||
$this->expectException(\InvalidArgumentException::class); | ||
$cache->withToken($tokenRequestContext, $this->createMock(AccessToken::class)); | ||
} | ||
|
||
public function testWithTokenThrowsExceptionIfTokenRequestContextAlreadyExists() { | ||
$cache = new InMemoryAccessTokenCache($this->testTokenRequestContext, $this->createMock(AccessToken::class)); | ||
$this->expectException(\InvalidArgumentException::class); | ||
$cache->withToken($this->testTokenRequestContext, $this->createMock(AccessToken::class)); | ||
} | ||
|
||
public function testWithTokenAddsMultipleTokensToCache() { | ||
$secondContext = $this->createMock(TokenRequestContext::class); | ||
$secondContext->method('getCacheKey')->willReturn('second-key'); | ||
|
||
$cache = (new InMemoryAccessTokenCache()) | ||
->withToken($this->testTokenRequestContext, $this->createMock(AccessToken::class)) | ||
->withToken($secondContext, $this->createMock(AccessToken::class)); | ||
|
||
$this->assertInstanceOf(AccessToken::class, $cache->getTokenWithContext($this->testTokenRequestContext)); | ||
$this->assertInstanceOf(AccessToken::class, $cache->getTokenWithContext($secondContext)); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.