Add initial project configuration and test setup

This commit is contained in:
netkas 2024-09-13 13:51:03 -04:00
parent 178e16627f
commit 7d2b2242aa
9 changed files with 110 additions and 0 deletions

12
.idea/dataSources.xml generated Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="Socialbox" uuid="45759e9e-7247-452b-98b8-e097518b48eb">
<driver-ref>mariadb</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mariadb://127.0.0.1:3306/socialbox</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View file

@ -0,0 +1,12 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="IncorrectHttpHeaderInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="customHeaders">
<set>
<option value=" &quot;params&quot;" />
</set>
</option>
</inspection_tool>
</profile>
</component>

15
.idea/php-test-framework.xml generated Normal file
View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpTestFrameworkVersionCache">
<tools_cache>
<tool tool_name="PHPUnit">
<cache>
<versions>
<info id="interpreter-97a5bd20-380b-4ced-b7c8-1ab65b74addb" version="11.3.4" />
<info id="interpreter-ca3a8963-de43-46f5-b440-698923ca9fc3" version="11.3.4" />
</versions>
</cache>
</tool>
</tools_cache>
</component>
</project>

6
.idea/sqldialects.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/src/Socialbox/Managers/SessionManager.php" dialect="MariaDB" />
</component>
</project>

14
.idea/webResources.xml generated Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WebResourcesPaths">
<contentEntries>
<entry url="file://$PROJECT_DIR$">
<entryData>
<resourceRoots>
<path value="file://$PROJECT_DIR$/examples" />
</resourceRoots>
</entryData>
</entry>
</contentEntries>
</component>
</project>

1
.phpunit.result.cache Normal file
View file

@ -0,0 +1 @@
{"version":1,"defects":{"SocialBox\\Objects\\RpcRequestTest::testConstructorWithIdAndParametersMissing":4,"SocialBox\\Objects\\RpcRequestTest::testConstructorWithAllParametersPresent":4,"Error":4,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPairThrowsExceptionOnFailure with data set #0":5,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPair":8,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPairException":7,"Socialbox\\Classes\\CryptographyTest::testTemporarySignature":8,"Socialbox\\Classes\\CryptographyTest::testVerifyTemporarySignature":8,"Socialbox\\Classes\\CryptographyTest::testEncrypt":8,"Socialbox\\Classes\\CryptographyTest::testDecrypt":8,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithValidPublicKey":8,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithEmptyPublicKey":7,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithDbException":7,"Socialbox\\Managers\\SessionManagerTest::testCreateSession":8,"Socialbox\\Classes\\CryptographyTest::testSignContent":8,"Socialbox\\Classes\\CryptographyTest::testVerifyContent":8,"Socialbox\\Classes\\CryptographyTest::testDecryptFromFile":7,"Socialbox\\Managers\\SessionManagerTest::testGetSessionWithInvalidUuid":8,"Socialbox\\Managers\\SessionManagerTest::testGetSessionWithValidUuid":8,"Socialbox\\Managers\\SessionManagerTest::testUpdateSessionWithValidSessionRecord":8,"Socialbox\\Managers\\SessionManagerTest::testUpdateSessionWithInvalidUuid":7,"Socialbox\\Managers\\SessionManagerTest::testUpdateAuthenticatedPeerWithInvalidUuid":7,"Socialbox\\Managers\\SessionManagerTest::testUpdateAuthenticatedPeerWithValidUuid":8,"Socialbox\\Managers\\SessionManagerTest::testUpdateLastRequestWithInvalidUuid":7,"Socialbox\\Managers\\SessionManagerTest::testUpdateLastRequest":8,"Socialbox\\Classes\\CryptographyTest::testValidatePublicKey":7},"times":{"SocialBox\\Objects\\RpcRequestTest::testConstructorWithIdAndParametersMissing":0.001,"SocialBox\\Objects\\RpcRequestTest::testConstructorWithAllParametersPresent":0,"Error":0,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPair with data set #0":0.007,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPairThrowsExceptionOnFailure with data set #0":0.224,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPair":0.142,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPairException":0.114,"Socialbox\\Classes\\CryptographyTest::testSignContent":0.382,"Socialbox\\Classes\\CryptographyTest::testVerifyContent":0.5,"Socialbox\\Classes\\CryptographyTest::testTemporarySignature":0.198,"Socialbox\\Classes\\CryptographyTest::testVerifyTemporarySignature":0.253,"Socialbox\\Classes\\CryptographyTest::testEncrypt":0.117,"Socialbox\\Classes\\CryptographyTest::testDecrypt":0.506,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithValidPublicKey":0.004,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithEmptyPublicKey":0.002,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithDbException":0.053,"Socialbox\\Managers\\SessionManagerTest::testCreateSession":0.339,"Socialbox\\Classes\\CryptographyTest::testEncryptFromFile":0.002,"Socialbox\\Classes\\CryptographyTest::testDecryptFromFile":0.004,"Socialbox\\Managers\\SessionManagerTest::testGetSessionWithInvalidUuid":0.002,"Socialbox\\Managers\\SessionManagerTest::testGetSessionWithValidUuid":0.297,"Socialbox\\Managers\\SessionManagerTest::testUpdateSessionWithValidSessionRecord":0.249,"Socialbox\\Managers\\SessionManagerTest::testUpdateSessionWithInvalidUuid":0.183,"Socialbox\\Managers\\SessionManagerTest::testUpdateAuthenticatedPeerWithInvalidUuid":0.002,"Socialbox\\Managers\\SessionManagerTest::testUpdateAuthenticatedPeerWithValidUuid":0.32,"Socialbox\\Managers\\SessionManagerTest::testUpdateLastRequestWithInvalidUuid":0.001,"Socialbox\\Managers\\SessionManagerTest::testUpdateLastRequest":0.441,"Socialbox\\Classes\\CryptographyTest::testValidatePublicKey":0.362,"Socialbox\\Classes\\CryptographyTest::testValidateInvalidPublicKey":0.003,"Socialbox\\Classes\\CryptographyTest::testValidatePrivateKey":0.184,"Socialbox\\Classes\\CryptographyTest::testValidateInvalidPrivateKey":0.004}}

6
examples/index.php Normal file
View file

@ -0,0 +1,6 @@
<?php
require 'ncc';
import('net.nosial.socialbox');
\Socialbox\Socialbox::handleRpc();

11
tests/ping.http Normal file
View file

@ -0,0 +1,11 @@
< {%
import {randomCrc32String} from "./utilities.js";
request.variables.set("id", randomCrc32String());
%}
POST http://172.27.7.211/
Content-Type: application/json
{
"method": "ping",
"id": "{{id}}"
}

33
tests/utilities.js Normal file
View file

@ -0,0 +1,33 @@
export function crc32(str) {
var crcTable = [];
for (var i = 0; i < 256; i++) {
var crc = i;
for (var j = 8; j > 0; j--) {
if (crc & 1) {
crc = (crc >>> 1) ^ 0xEDB88320;
} else {
crc = crc >>> 1;
}
}
crcTable[i] = crc;
}
var crc32val = 0xFFFFFFFF;
for (var i = 0; i < str.length; i++) {
var charCode = str.charCodeAt(i);
crc32val = (crc32val >>> 8) ^ crcTable[(crc32val ^ charCode) & 0xFF];
}
return (crc32val ^ 0xFFFFFFFF) >>> 0;
}
export function randomCrc32String(length = 8) {
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var randomStr = '';
for (var i = 0; i < length; i++) {
randomStr += characters.charAt(Math.floor(Math.random() * characters.length));
}
return crc32(randomStr).toString(16); // Convert to hexadecimal string
}
console.log(randomCrc32String()); // Example usage