/**
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014 - 2015 ForgeRock AS.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
#include "platform.h"
#include "am.h"
#include "utility.h"
#include "list.h"
#include "thread.h"
#include "cmocka.h"
void am_worker_pool_init_reset();
void am_net_init_ssl_reset();
void dump_cache_memory(void);
"<PolicyResponse requestId='4' issueInstant='1424783306343' >"
" <ResourceResult name='http://vb2.local.com:80/testwebsite'>"
" <PolicyDecision>"
" <ResponseAttributes> <!-- these can have multiple (0..n) value elements -->"
" <AttributeValuePair>"
" <Attribute name='Attributes,key:0,0'/> <Value>Attributes,value:0,0,0</Value> <Value>Attributes,value:0,0,1</Value>"
" </AttributeValuePair>"
" <AttributeValuePair>"
" <Attribute name='Attributes,key:0,1'/> <Value>Attributes,value:0,1,0</Value>"
" </AttributeValuePair>"
" </ResponseAttributes>"
" <ActionDecision timeToLive='1234'> <!-- these can have no value elements, which defaults to ? -->"
" <AttributeValuePair>"
" <Attribute name='PUT'/> <Value>deny</Value>"
" </AttributeValuePair>"
" <Advices>"
" <AttributeValuePair>"
" <Attribute name='Advices,key:0,0'/> <Value>Advices,value:0,0,0</Value>"
" </AttributeValuePair>"
" <AttributeValuePair>"
" <Attribute name='Advices,key:0,1'/> <Value>Advices,value:0,1,0</Value>"
" </AttributeValuePair>"
" </Advices>"
" </ActionDecision>"
" <ActionDecision timeToLive='5678'>"
" <AttributeValuePair>"
" <Attribute name='GET'/> <Value>allow</Value>"
" </AttributeValuePair>"
" <Advices>"
" <AttributeValuePair>"
" <Attribute name='Advices,key:0,0'/> <Value>Advices,value:0,0,0</Value>"
" </AttributeValuePair>"
" <AttributeValuePair>"
" <Attribute name='Advices,key:0,1'/> <Value>Advices,value:0,1,0</Value>"
" </AttributeValuePair>"
" </Advices>"
" </ActionDecision>"
" <ActionDecision timeToLive='9012'>"
" <AttributeValuePair>"
" <Attribute name='POST'/> <Value>allow</Value>"
" </AttributeValuePair>"
" <Advices>"
" <AttributeValuePair>"
" <Attribute name='Advices,key:0,0'/> <Value>Advices,value:0,0,0</Value>"
" </AttributeValuePair>"
" <AttributeValuePair>"
" <Attribute name='Advices,key:0,1'/> <Value>Advices,value:0,1,0</Value>"
" </AttributeValuePair>"
" <AttributeValuePair>"
" <Attribute name='Advices,key:0,2'/> <Value>Advices,value:0,2,0</Value>"
" </AttributeValuePair>"
" </Advices>"
" </ActionDecision>"
" <ResponseDecisions>"
" <AttributeValuePair>"
" <Attribute name='Decision,key:0,0'/> <Value>Decision,value:0,0,0</Value>"
" </AttributeValuePair>"
" <AttributeValuePair>"
" <Attribute name='Decision,key:0,1'/> <Value>Decision,value:0,1,0</Value>"
" </AttributeValuePair>"
" <AttributeValuePair>"
" <Attribute name='Decision,key:0,2'/> <Value>Decision,value:0,2,0</Value>"
" </AttributeValuePair>"
" </ResponseDecisions>"
" </PolicyDecision>"
" </ResourceResult>"
"</PolicyResponse>"
"</PolicyService>";
char* policy_for_url =
"<PolicyService version=\"1.0\" revisionNumber=\"60\">"
" <PolicyResponse requestId=\"4\" issueInstant=\"9999999999999\" >"
" <ResourceResult name=\"%s\">"
" <PolicyDecision>"
" <ResponseAttributes>"
" </ResponseAttributes>"
" <ActionDecision timeToLive=\"9999999999999999999\">"
" <AttributeValuePair>"
" <Attribute name=\"POST\"/>"
" <Value>allow</Value>"
" </AttributeValuePair>"
" <Advices>"
" </Advices>"
" </ActionDecision>"
" <ActionDecision timeToLive=\"9999999999999999999\">"
" <AttributeValuePair>"
" <Attribute name=\"PATCH\"/>"
" <Value>allow</Value>"
" </AttributeValuePair>"
" <Advices>"
" </Advices>"
" </ActionDecision>"
" <ActionDecision timeToLive=\"9999999999999999999\">"
" <AttributeValuePair>"
" <Attribute name=\"GET\"/>"
" <Value>allow</Value>"
" </AttributeValuePair>"
" <Advices>"
" </Advices>"
" </ActionDecision>"
" <ActionDecision timeToLive=\"9999999999999999999\">"
" <AttributeValuePair>"
" <Attribute name=\"DELETE\"/>"
" <Value>allow</Value>"
" </AttributeValuePair>"
" <Advices>"
" </Advices>"
" </ActionDecision>"
" <ActionDecision timeToLive=\"9999999999999999999\">"
" <AttributeValuePair>"
" <Attribute name=\"OPTIONS\"/>"
" <Value>allow</Value>"
" </AttributeValuePair>"
" <Advices>"
" </Advices>"
" </ActionDecision>"
" <ActionDecision timeToLive=\"9999999999999999999\">"
" <AttributeValuePair>"
" <Attribute name=\"HEAD\"/>"
" <Value>allow</Value>"
" </AttributeValuePair>"
" <Advices>"
" </Advices>"
" </ActionDecision>"
" <ActionDecision timeToLive=\"9999999999999999999\">"
" <AttributeValuePair>"
" <Attribute name=\"PUT\"/>"
" <Value>allow</Value>"
" </AttributeValuePair>"
" <Advices>"
" </Advices>"
" </ActionDecision>"
" </PolicyDecision>"
" </ResourceResult>"
" </PolicyResponse>"
"</PolicyService>";
"<ResponseSet vers='1.0' svcid='poicy' reqid='48'>"
" <Response><![CDATA[%s]]></Response>"
"</ResponseSet>";
/**
* Substitute our chosen URL into the "policy for url" string above. That way we can pretend
* we're getting different responses for different URLs. All the values are "allow" anyway.
*/
return NULL;
}
return result;
}
{
assert_int_equal(sscanf(nvp->v, value_format, &value_policy_seq, &value_attr_seq, &value_value_seq), 3);
}
{
int count = 0;
count++;
}
return count;
}
{
struct am_policy_result* r = result;
assert_non_null(r);
}
/***************************************************************************************************/
}
(*pcount)++;
}
static void cleardown() {
int clearup_count = 0;
//printf("hit return to continue\n");
//getc(stdin);
}
struct am_policy_result * r = NULL;
// destroy the cache, if it exists
cleardown();
}
{
int i;
for (i = 0; i < count; i++) {
}
}
static int test_cache_with_seed(int seed, int test_size, am_request_t * request, struct am_policy_result * result, am_bool_t error)
{
int i;
/* create initial entries */
for(i = 0; i < test_size; i++) {
printf("test_cache_with_seed: capacity is %d\n", i);
capacity = i;
break;
}
if (i % 10000 == 0)
printf("loaded %d..\n", i);
}
/* should refresh the whole lot */
for(i = 0; i < capacity; i++) {
if (error)
else
if (i % 10000 == 0)
printf("reloaded %d..\n", i);
}
/* read them all back */
for(i = 0; i < capacity; i++) {
struct am_policy_result * r = NULL;
if (error) {
}
if (i % 10000 == 0)
printf("read %d..\n", i);
}
return capacity;
}
}
static void test_cache_keys(int test_size, char** keys, am_request_t* request, struct am_policy_result* result)
{
int i;
/* create initial entries */
for(i = 0; i < test_size; i++) {
}
/* should refresh the whole lot */
for(i = 0; i < test_size; i++) {
}
/* read them all back */
for(i = 0; i < test_size; i++) {
struct am_policy_result * r = NULL;
assert_int_equal(am_get_session_policy_cache_entry(request, keys [i], &r, &session, &ets), AM_SUCCESS);
}
}
// destroy the cache, if it exists
cleardown();
}
int capacity;
// destroy the cache, if it exists
cleardown();
}
int loaded;
long elapsed;
// destroy the cache, if it exists
cleardown();
// time load to capacity
printf("starting timing phase..\n");
// wait the TTL to expire
// this update should trigger purge
printf("verifying expiry during load.. \n");
}
/**
* Now vary the incoming URL a bit and check we can get the same values out.
*/
int i;
char* urls[] = {
};
// destroy the cache, if it exists
cleardown();
/**
* Add the URLS above into the cache via the same session id
*/
assert_int_equal(am_add_session_policy_cache_entry(&request, fake_session, policy_result, NULL), AM_SUCCESS);
}
/**
* Check we can retrieve the URLs above from the cache via the same session id
*/
struct am_policy_result * r = NULL;
}
}
}
} else {
}
}
}
struct test_cache_params {
int test_size;
int iterations;
};
{
int i;
struct test_cache_params * p = params;
for (i = 0; i < p->iterations; i++) {
}
return 0;
}
/* this must be slightly less than the maximum because re-use of shm chunks might use more space */
int i;
cleardown();
.iterations = 1,
};
double dt;
for (i = 0; i < NTHREADS; i++) {
}
for (i = 0; i < NTHREADS; i++) {
AM_THREAD_JOIN(threads[i]);
}
}
}
/**
* This is an internal test of the mechanism for replaying a given number of randomly generated strings
*/
int i;
srand(543542);
for(i = 0; i < TEST_SIZE_1; i++) {
}
srand(543542);
for(i = 0; i < TEST_SIZE_1; i++) {
}
}