Subversion Repositories oidplus

Rev

Rev 557 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

#!/usr/bin/env php
<?php

/*
 * OIDplus 2.0
 * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

use ViaThinkSoft\OIDplus\OIDplus;

require_once __DIR__ . '/../includes/oidplus.inc.php';

OIDplus::init(false);

// This file tests all log events (to verify that the logmasks are working)
// PLEASE DO NOT RUN THIS FILE ON A PRODUCTION DATABASE, BECAUSE IT WILL FILL YOUR LOG FILE WITH CRAP!

$id = 'oid:2.999';
$email = 'oidra@viathinksoft.de';
$old_email = 'oidra@viathinksoft.de';
$new_email = 'oidra@viathinksoft.de';
$current_ra = 'oidra@viathinksoft.de';
$new_ra = 'oidra@viathinksoft.de';
$ra_email = 'oidra@viathinksoft.de';
$name = 'CFD';
$value = 'VAL';
$ra_name = 'Daniel';
$root_oid = '2.123';
$parent = 'oid:2';
$new_oid = 'oid:2.999.1';
$system_id = '12345';
$parent_oid = 'oid:2.998';
$id_to_delete = 'oid:2.999';

// These are all lines of code that contain 'OIDplus::logger()->log'

OIDplus::logger()->log("[INFO]A!", "Generating new SystemID using a new key pair");
OIDplus::logger()->log("[INFO]A!", "Your SystemID is now $system_id");
OIDplus::logger()->log("[OK]A?", "Changed system config setting '$name' to '$value'");
OIDplus::logger()->log("[WARN]A!", "Removing SystemID and key pair because there is a hash conflict with another OIDplus system!");

OIDplus::logger()->log("[INFO]RA($email)!/A?", "RA '$email' was created by the admin, without email address verification or invitation");



OIDplus::logger()->log("[OK]A?", "Changed system color theme");
OIDplus::logger()->log("[WARN]OID($id)+[?WARN/!OK]SUPOIDRA($id)?/[?INFO/!OK]A?", "Object '$id' (recursively) deleted");
OIDplus::logger()->log("[CRIT]OIDRA($id)!", "Lost ownership of object '$id' because it was deleted");
OIDplus::logger()->log("[WARN]OID($parent_oid)", "Object '$id' (recursively) deleted");
OIDplus::logger()->log("[CRIT]OIDRA($id_to_delete)!", "Lost ownership of object '$id_to_delete' because one of the superior objects ('$id') was recursively deleted");
OIDplus::logger()->log("[INFO]OID($id)+[?INFO/!OK]SUPOIDRA($id)?/[?INFO/!OK]A?", "RA of object '$id' changed from '$current_ra' to '$new_ra'");
OIDplus::logger()->log("[WARN]RA($current_ra)!",           "Lost ownership of object '$id' due to RA transfer of superior RA / admin.");
OIDplus::logger()->log("[INFO]RA($new_ra)!",               "Gained ownership of object '$id' due to RA transfer of superior RA / admin.");
OIDplus::logger()->log("[INFO]OID($parent_oid)", "RA of object '$id' changed from '$current_ra' to '$new_ra'");
OIDplus::logger()->log("[INFO]OID($id)+[?INFO/!OK]SUPOIDRA($id)?/[?INFO/!OK]A?", "Identifiers/Confidential flag of object '$id' updated"); // TODO: Check if they were ACTUALLY updated!
OIDplus::logger()->log("[INFO]OID($parent_oid)", "Identifiers/Confidential flag of object '$id' updated"); // TODO: Check if they were ACTUALLY updated!
OIDplus::logger()->log("[INFO]OID($id)+[?INFO/!OK]OIDRA($id)?/[?INFO/!OK]A?", "Title/Description of object '$id' updated");
OIDplus::logger()->log("[INFO]OID($parent)+[INFO]OID($id)+[?INFO/!OK]OIDRA($parent)?/[?INFO/!OK]A?", "Object '$id' created, ".(empty($ra_email) ? "without defined RA" : "given to RA '$ra_email'")).", superior object is '$parent'";
OIDplus::logger()->log("[INFO]RA($ra_email)!", "Gained ownership of newly created object '$id'");
OIDplus::logger()->log("[?WARN/!OK]RA($email)!/[?INFO/!OK]A?", "RA '$email' deleted");
OIDplus::logger()->log("[OK]RA($email)!", "RA '$email' logged in");
OIDplus::logger()->log("[OK]RA($email)!", "RA '$email' logged out");
OIDplus::logger()->log("[OK]A!", "Admin logged in");
OIDplus::logger()->log("[OK]A!", "Admin logged out");
OIDplus::logger()->log("[WARN]RA($email)!", "A new password for '$email' was requested (forgot password)");
OIDplus::logger()->log("[INFO]RA($email)!", "RA '$email' has reset his password (forgot passwort)");
OIDplus::logger()->log("[INFO]OID(oid:$root_oid)+RA($email)!", "Requested a free OID for email '$email' to be placed into root '$root_oid'");
OIDplus::logger()->log("[INFO]OID(oid:$root_oid)+OIDRA(oid:$root_oid)!", "Child OID '$new_oid' added automatically by '$email' (RA Name: '$ra_name')");
OIDplus::logger()->log("[INFO]OID(oid:$new_oid)+[OK]RA($email)!",            "Free OID '$new_oid' activated (RA Name: '$ra_name')");
OIDplus::logger()->log("[INFO]RA($email)!", "RA '$email' has been invited");
OIDplus::logger()->log("[OK]RA($email)!", "RA '$email' has been registered due to invitation");
OIDplus::logger()->log("[?WARN/!OK]RA($email)?/[?INFO/!OK]A?", "Changed RA '$email' contact data/details");
OIDplus::logger()->log("[?WARN/!OK]RA($email)?/[?INFO/!OK]A?", "Password of RA '$email' changed");
OIDplus::logger()->log("[WARN]RA($old_email)!+[INFO]RA($new_email)!+[OK]A!", "Admin changed email address '$old_email' to '$new_email'");
OIDplus::logger()->log("[INFO]RA($old_email)!+RA($new_email)!", "Requested email address change from '$old_email' to '$new_email'");
OIDplus::logger()->log("[OK]RA($new_email)!+RA($old_email)!", "RA '$old_email' has changed their email address to '$new_email'");

$msg = "test";
$uploadfile = "test";
OIDplus::logger()->log("[ERR]OID($id)+[ERR]A!", $msg);
OIDplus::logger()->log("[OK]OID($id)+[?INFO/!OK]OIDRA($id)?/[?INFO/!OK]A?", "Deleted attachment '".basename($uploadfile)."' from object '$id'");
OIDplus::logger()->log("[ERR]OID($id)+[ERR]A!", $msg);
OIDplus::logger()->log("[OK]OID($id)+[?INFO/!OK]OIDRA($id)?/[?INFO/!OK]A?", "Uploaded attachment '".basename($uploadfile)."' to object '$id'");

echo "Done";