/** * @group unit * @group utility */ public function testFindValidScopeForClientWithScopes() { $client = array('scope' => array('SCOPE1' => false, 'SCOPE2' => false)); $scopes = array('SCOPE1', 'SCOPE3'); $result = \sspmod_oauth2server_Utility_Uri::findValidScopes($client, $scopes); $this->assertEquals(array(0 => 'SCOPE1'), $result); }
$idAttribute = $config->getValue('user_id_attribute', 'eduPersonScopedAffiliation'); $attributes = $as->getAttributes(); if ($state['response_type'] === 'code') { $authorizationCodeFactory = new sspmod_oauth2server_OAuth2_TokenFactory($authorizationCodeTTL, $accessTokenTTL, $tokenTTL); $token = $authorizationCodeFactory->createAuthorizationCode($state['clientId'], $state['redirectUri'], array(), $attributes[$idAttribute][0]); } else { $authorizationCodeFactory = new sspmod_oauth2server_OAuth2_TokenFactory($authorizationCodeTTL, $tokenTTL, $tokenTTL); $token = $authorizationCodeFactory->createBearerAccessToken($state['clientId'], array(), $attributes[$idAttribute][0]); } if (isset($_REQUEST['grantedScopes'])) { $scopesTemp = $_REQUEST['grantedScopes']; } else { $scopesTemp = array(); } \sspmod_oauth2server_Utility_Uri::augmentRequestedScopesWithRequiredScopes($client, $scopesTemp); $token['scopes'] = \sspmod_oauth2server_Utility_Uri::findValidScopes($client, $scopesTemp); $tokenStore = new sspmod_oauth2server_OAuth2_TokenStore($config); if ($state['response_type'] === 'code') { $tokenStore->addAuthorizationCode($token); } else { $tokenStore->addAccessToken($token); } $userStore = new sspmod_oauth2server_OAuth2_UserStore($config); $user = $userStore->getUser($token['userId']); if (is_array($user)) { $user['attributes'] = $as->getAttributes(); $liveTokens = array($token['id']); if ($state['response_type'] === 'code') { foreach ($user['authorizationCodes'] as $tokenId) { if (!is_null($tokenStore->getAuthorizationCode($tokenId))) { array_push($liveTokens, $tokenId);