<?php

/**
 * @file
 * Pugpig Subscription Test Page
 */
/*

Licence:
==============================================================================
(c) 2011, Kaldor Holdings Ltd
This module is released under the GNU General Public License.
See COPYRIGHT.txt and LICENSE.txt
*/
include_once 'pugpig_utilities.php';
include_once 'pugpig_interface.php';
include_once 'pugpig_subs_test.php';
if (!file_exists('standalone_config.php')) {
    echo "<h2>Warning - standalone_config.php not found</h2>";
    echo "In order to use this page, you will need to configure settings in the file: <code>standalone_config.php</code>";
    exit;
}
include_once 'standalone_config.php';
pugpig_interface_output_header("Pugpig - Subscription Test Page");
pugpig_subs_test_form($title, $urls, $params, $test_users);
/**
 * @file
 * Pugpig Auth Test Form
 */
/*

Licence:
==============================================================================
(c) 2011, Kaldor Holdings Ltd
This module is released under the GNU General Public License.
See COPYRIGHT.txt and LICENSE.txt
*/
include_once "auth_test_inc.php";
//$active = patcf_flip_is_active($seconds_left);
//print "SECONDS: $seconds_left<br />";
$title = "Generic Test Stub";
$v["issue_prefix"] = "com.pugpig.edition";
$v["issue_start"] = 1;
$v["issue_end"] = 100;
$base = pugpig_get_current_base_url() . $_SERVER["SCRIPT_NAME"] . "?" . http_build_query($v);
$urls["sign_in"] = str_replace("test_form", "sign_in", $base);
$urls["verify_subscription"] = str_replace("test_form", "verify_subscription", $base);
$urls["edition_credentials"] = str_replace("test_form", "edition_credentials", $base);
$urls["renew_token"] = str_replace("test_form", "renew_token", $base);
$urls["sign_out"] = str_replace("test_form", "sign_out", $base);
$params = array("username", "password");
$test_users = patcf_get_test_users($all_users);
$helptext = "Users of the form XXX-XXX-XXX will return the status code XXX specified for the three calls in the given order (Sign In, Verify, Edition Creds). 000 means return a 200 with rubbish. ZZZ returns a 200 but takes 60 seconds. Peter is the only user requiring a password.<br/> Issues listed below may be free, empty or broken. Users with names ending in global set global auth creds. Please check your OPDS feed to make sure the issues function correctly.";
pugpig_subs_test_form($title, $urls, $params, $test_users, $helptext);
function _dovetail_test_form($url, $clientRef, $brandRefList, $test_user_string = '')
{
    // https://staging-dovetailrestfulservice.subscribeonline.co.uk/fulfillment-integration/sign-in?sourceSystem=MASS&clientRef=XXX&brandRef=YYY&webId=12345
    $title = "Dovetail Test Form (Client: {$clientRef}, Brands: {$brandRefList})";
    $urls["sign_in"] = pugpig_get_current_base_url() . "/dovetail_sign_in/";
    $urls["verify_subscription"] = pugpig_get_current_base_url() . "/dovetail_verify_subscription/";
    $urls["edition_credentials"] = pugpig_get_current_base_url() . "/dovetail_edition_credentials/";
    $params = array("webId");
    $test_users = pugpig_subs_get_test_user_array($params, $test_user_string);
    pugpig_subs_test_form($title, $urls, $params, $test_users);
    exit;
    // Don't do the usual Drupal caching headers etc when completing the request
}
 * Pugpig Subscription Test Page
 */
/*

Licence:
==============================================================================
(c) 2011, Kaldor Holdings Ltd
This module is released under the GNU General Public License.
See COPYRIGHT.txt and LICENSE.txt
*/
include_once 'pugpig_utilities.php';
include_once 'pugpig_interface.php';
include_once 'pugpig_subs_test.php';
if (!file_exists('standalone_config.php')) {
    echo "<h2>Warning - standalone_config.php not found</h2>";
    echo "In order to use this page, you will need to configure settings in the file: <code>standalone_config.php</code>";
    exit;
}
include_once 'standalone_config.php';
pugpig_interface_output_header("Pugpig - Subscription Test Page");
if (!isset($helptext)) {
    $helptext = "This is a generic test form which needs to be configured.";
}
if (!isset($use_http_post)) {
    $use_http_post = false;
}
if (!isset($auth_test_default_product_id)) {
    $auth_test_default_product_id = 'com.pugpig.edition0100';
}
pugpig_subs_test_form($title, $urls, $params, $test_users, $helptext, $use_http_post, $auth_test_default_product_id);