Initial Commit
This commit is contained in:
parent
93a0b9be02
commit
6e599b2c0c
99 changed files with 10836 additions and 4 deletions
18
tests/base32_test.php
Normal file
18
tests/base32_test.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
require 'ncc';
|
||||
import('net.nosial.federationlib');
|
||||
|
||||
|
||||
$data = "Hello World!";
|
||||
print(sprintf("Original data: %s\n", $data));
|
||||
|
||||
$encoded = \FederationLib\Classes\Base32::encode($data);
|
||||
print(sprintf("Encoded data: %s\n", $encoded));
|
||||
|
||||
$decoded = \FederationLib\Classes\Base32::decode($encoded);
|
||||
print(sprintf("Decoded data: %s\n", $decoded));
|
||||
|
||||
print(sprintf("Original data equals decoded data: %s\n", $data === $decoded ? 'true' : 'false'));
|
||||
exit(0);
|
||||
|
25
tests/client_manager/cache_update_test.php
Normal file
25
tests/client_manager/cache_update_test.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
require 'ncc';
|
||||
|
||||
import('net.nosial.federationlib');
|
||||
$federationlib = new \FederationLib\FederationLib();
|
||||
|
||||
$client = new \FederationLib\Objects\Client();
|
||||
$client->setDescription('This is a test client generated by a test script.');
|
||||
|
||||
$uuid = $federationlib->getClientManager()->registerClient($client);
|
||||
|
||||
print(sprintf('Client UUID: %s', $uuid) . PHP_EOL);
|
||||
|
||||
$client = $federationlib->getClientManager()->getClient($uuid);
|
||||
$client->setName('Test Client');
|
||||
$client->setDescription('This is a test client generated by a test script. It has been updated.');
|
||||
|
||||
$federationlib->getClientManager()->updateClient($client);
|
||||
|
||||
$client = $federationlib->getClientManager()->getClient($uuid);
|
||||
print(sprintf('Client name: %s', $client->getName()) . PHP_EOL);
|
||||
print(sprintf('Client description: %s', $client->getDescription()) . PHP_EOL);
|
||||
|
||||
exit(0);
|
14
tests/client_manager/create_client.php
Normal file
14
tests/client_manager/create_client.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
require 'ncc';
|
||||
|
||||
import('net.nosial.federationlib');
|
||||
$federationlib = new \FederationLib\FederationLib();
|
||||
|
||||
$client = new \FederationLib\Objects\Client();
|
||||
$client->setDescription('This is a test client generated by a test script.');
|
||||
|
||||
$uuid = $federationlib->getClientManager()->registerClient($client);
|
||||
|
||||
print(sprintf('Client UUID: %s', $uuid) . PHP_EOL);
|
||||
exit(0);
|
18
tests/client_manager/create_secured_client.php
Normal file
18
tests/client_manager/create_secured_client.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
require 'ncc';
|
||||
|
||||
import('net.nosial.federationlib');
|
||||
$federationlib = new \FederationLib\FederationLib();
|
||||
|
||||
// loop 50 times to create 50 clients
|
||||
for($i = 0; $i < 50; $i++)
|
||||
{
|
||||
$client = new \FederationLib\Objects\Client();
|
||||
$client->setDescription('This is a test client generated by a test script.');
|
||||
$client->enableAuthentication();
|
||||
|
||||
$uuid = $federationlib->getClientManager()->registerClient($client);
|
||||
|
||||
print(sprintf('Client UUID: %s', $uuid) . PHP_EOL);
|
||||
}
|
8
tests/client_manager/list_clients.php
Normal file
8
tests/client_manager/list_clients.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
require 'ncc';
|
||||
|
||||
import('net.nosial.federationlib');
|
||||
$federationlib = new \FederationLib\FederationLib();
|
||||
|
||||
var_dump($federationlib->getClientManager()->listClients(1));
|
15
tests/totp_test.php
Normal file
15
tests/totp_test.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
require 'ncc';
|
||||
import('net.nosial.federationlib');
|
||||
|
||||
$secret_file = __DIR__ . DIRECTORY_SEPARATOR . 'secret.txt';
|
||||
if(!file_exists($secret_file))
|
||||
{
|
||||
file_put_contents($secret_file, \FederationLib\Classes\Security::generateSecret());
|
||||
}
|
||||
|
||||
$secret = file_get_contents($secret_file);
|
||||
$code = \FederationLib\Classes\Security::generateCode($secret);
|
||||
print(sprintf("Code: %s\n", $code));
|
||||
exit(0);
|
Loading…
Add table
Add a link
Reference in a new issue