<commit_before><?php
/**
 * SSO data Test implementation, based on this doc:
 * https://developers.staffbase.com/api/plugin-sso/
 *
 * PHP version 5.5.9
 *
 * @category  Authentication
 * @copyright 2017 Staffbase, GmbH. 
 * @author    <NAME>
 * @license   http://www.apache.org/licenses/LICENSE-2.0
 * @link      https://github.com/staffbase/plugins-sdk-php
 */
namespace Staffbase\plugins\test;

use PHPUnit_Framework_TestCase as TestCase;
use Staffbase\plugins\sdk\SSOData;

class SSODataTest extends TestCase {

	private $classname = SSOData::class;

	/**
	 * Create test data for a token.
	 *
	 * Can be used in development in conjunction with
	 * createSignedTokenFromData to issue development tokens.
	 *
	 * @return array Associative array of claims.
	 */
	public static function getTokenData() {

		$tokenData = [];

		$tokenData[SSOData::CLAIM_AUDIENCE]               = 'testPlugin';
		$tokenData[SSOData::CLAIM_EXPIRE_AT]              = strtotime('10 minutes');
		$tokenData[SSOData::CLAIM_NOT_BEFORE]             = strtotime('-1 minute');
		$tokenData[SSOData::CLAIM_ISSUED_AT]              = time();
		$tokenData[SSOData::CLAIM_ISSUER]                 = 'api.staffbase.com';
		$tokenData[SSOData::CLAIM_INSTANCE_ID]            = '<KEY>';
		$tokenData[SSOData::CLAIM_INSTANCE_NAME]          = 'Our locations';
		$tokenData[SSOData::CLAIM_USER_ID]                = '<KEY>';
		$tokenData[SSOData::CLAIM_USER_EXTERNAL_ID]       = 'jdoe';
		$tokenData[SSOData::CLAIM_USER_FULL_NAME]         = '<NAME>';
		$tokenData[SSOData::CLAIM_USER_FIRST_NAME]        = 'John';
		$tokenData[SSOData::CLAIM_USER_LAST_NAME]         = 'Doe';
		$tokenData[SSOData::CLAIM_USER_ROLE]              = 'editor';
		$tokenData[SSOData::CLAIM_ENTITY_TYPE]            = 'user';
		$tokenData[SSOData::CLAIM_THEME_TEXT_COLOR]       = '#00ABAB';
		$tokenData[SSOData::CLAIM_THEME_BACKGROUND_COLOR] = '#FFAABB';
		$tokenData[SSOData::CLAIM_USER_LOCALE]            = 'en-US';
		$tokenData[SSOData::CLAIM_USER_TAGS]              = ['profile:field1:val', 'profile:field2:val'];

		return $tokenData;
	}

	/**
	 * Get accessors map for supported tokens.
	 *
	 * @return array Associative array of claim accessors.
	 */
	public static function getTokenAccesors() {

		$acccessors = [];

		$acccessors[SSOData::CLAIM_AUDIENCE]               = 'getAudience';
		$acccessors[SSOData::CLAIM_EXPIRE_AT]              = 'getExpireAtTime';
		$acccessors[SSOData::CLAIM_NOT_BEFORE]             = 'getNotBeforeTime';
		$acccessors[SSOData::CLAIM_ISSUED_AT]              = 'getIssuedAtTime';
		$acccessors[SSOData::CLAIM_ISSUER]                 = 'getIssuer';
		$acccessors[SSOData::CLAIM_INSTANCE_ID]            = 'getInstanceId';
		$acccessors[SSOData::CLAIM_INSTANCE_NAME]          = 'getInstanceName';
		$acccessors[SSOData::CLAIM_USER_ID]                = 'getUserId';
		$acccessors[SSOData::CLAIM_USER_EXTERNAL_ID]       = 'getUserExternalId';
		$acccessors[SSOData::CLAIM_USER_FULL_NAME]         = 'getFullName';
		$acccessors[SSOData::CLAIM_USER_FIRST_NAME]        = 'getFirstName';
		$acccessors[SSOData::CLAIM_USER_LAST_NAME]         = 'getLastName';
		$acccessors[SSOData::CLAIM_USER_ROLE]              = 'getRole';
		$acccessors[SSOData::CLAIM_ENTITY_TYPE]            = 'getType';<commit_msg>update test data to match the actual output<commit_after><?php
/**
 * SSO data Test implementation, based on this doc:
 * https://developers.staffbase.com/api/plugin-sso/
 *
 * PHP version 5.5.9
 *
 * @category  Authentication
 * @copyright 2017 Staffbase, GmbH. 
 * @author    <NAME>
 * @license   http://www.apache.org/licenses/LICENSE-2.0
 * @link      https://github.com/staffbase/plugins-sdk-php
 */
namespace Staffbase\plugins\test;

use PHPUnit_Framework_TestCase as TestCase;
use Staffbase\plugins\sdk\SSOData;

class SSODataTest extends TestCase {

	private $classname = SSOData::class;

	/**
	 * Create test data for a token.
	 *
	 * Can be used in development in conjunction with
	 * createSignedTokenFromData to issue development tokens.
	 *
	 * @return array Associative array of claims.
	 */
	public static function getTokenData() {

		$tokenData = [];

		$tokenData[SSOData::CLAIM_AUDIENCE]               = 'testPlugin';
		$tokenData[SSOData::CLAIM_EXPIRE_AT]              = strtotime('10 minutes');
		$tokenData[SSOData::CLAIM_NOT_BEFORE]             = strtotime('-1 minute');
		$tokenData[SSOData::CLAIM_ISSUED_AT]              = time();
		$tokenData[SSOData::CLAIM_ISSUER]                 = 'api.staffbase.com';
		$tokenData[SSOData::CLAIM_INSTANCE_ID]            = '<KEY>';
		$tokenData[SSOData::CLAIM_INSTANCE_NAME]          = 'Our locations';
		$tokenData[SSOData::CLAIM_USER_ID]                = '541954c3e4b08bbdce1a340a';
		$tokenData[SSOData::CLAIM_USER_EXTERNAL_ID]       = 'jdoe';
		$tokenData[SSOData::CLAIM_USER_FULL_NAME]         = '<NAME>';
		$tokenData[SSOData::CLAIM_USER_FIRST_NAME]        = 'John';
		$tokenData[SSOData::CLAIM_USER_LAST_NAME]         = 'Doe';
		$tokenData[SSOData::CLAIM_USER_ROLE]              = 'editor';
		$tokenData[SSOData::CLAIM_ENTITY_TYPE]            = 'user';
		$tokenData[SSOData::CLAIM_THEME_TEXT_COLOR]       = '#00ABAB';
		$tokenData[SSOData::CLAIM_THEME_BACKGROUND_COLOR] = '#FFAABB';
		$tokenData[SSOData::CLAIM_USER_LOCALE]            = 'en_US';
		$tokenData[SSOData::CLAIM_USER_TAGS]              = ['profile:field1:val', 'profile:field2:val'];

		return $tokenData;
	}

	/**
	 * Get accessors map for supported tokens.
	 *
	 * @return array Associative array of claim accessors.
	 */
	public static function getTokenAccesors() {

		$acccessors = [];

		$acccessors[SSOData::CLAIM_AUDIENCE]               = 'getAudience';
		$acccessors[SSOData::CLAIM_EXPIRE_AT]              = 'getExpireAtTime';
		$acccessors[SSOData::CLAIM_NOT_BEFORE]             = 'getNotBeforeTime';
		$acccessors[SSOData::CLAIM_ISSUED_AT]              = 'getIssuedAtTime';
		$acccessors[SSOData::CLAIM_ISSUER]                 = 'getIssuer';
		$acccessors[SSOData::CLAIM_INSTANCE_ID]            = 'getInstanceId';
		$acccessors[SSOData::CLAIM_INSTANCE_NAME]          = 'getInstanceName';
		$acccessors[SSOData::CLAIM_USER_ID]                = 'getUserId';
		$acccessors[SSOData::CLAIM_USER_EXTERNAL_ID]       = 'getUserExternalId';
		$acccessors[SSOData::CLAIM_USER_FULL_NAME]         = 'getFullName';
		$acccessors[SSOData::CLAIM_USER_FIRST_NAME]        = 'getFirstName';
		$acccessors[SSOData::CLAIM_USER_LAST_NAME]         = 'getLastName';
		$acccessors[SSOData::CLAIM_USER_ROLE]              = 'getRole';
		$acccessors[SSOData::CLAIM_ENTITY_TYPE]            = 'getType';
{'fraction_non_alphanumeric': 0.1305669554643563, 'fraction_numerical': 0.006991944064447485, 'mean_word_length': 3.4131455399061035, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 10, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3059055', 'n_tokens_mistral': 2509, 'n_tokens_neox': 2239, 'n_words': 322}