40 class simple_infoton :
public infoton
45 simple_infoton() : infoton(simp_classifier()) {}
47 virtual void pack(byte_array &packed_form)
const {
48 futzle.pack(packed_form);
50 virtual bool unpack(byte_array &packed_form) {
51 if (!futzle.unpack(packed_form))
return false;
54 virtual int packed_size()
const {
return futzle.length() + 1; }
55 virtual clonable *clone()
const {
return new simple_infoton(*
this); }
65 class simple_tentacle :
public tentacle
68 simple_tentacle() : tentacle(simp_classifier(), true) {}
70 virtual outcome reconstitute(
const string_array &classifier,
71 byte_array &packed_form, infoton * &reformed) {
73 if (classifier != simp_classifier())
return NO_HANDLER;
74 reformed =
new simple_infoton;
75 if (!reformed->unpack(packed_form)) {
82 virtual outcome consume(infoton &to_chow,
83 const octopus_request_id &
formal(item_id), byte_array &transformed) {
85 if (to_chow.classifier() != simp_classifier())
return NO_HANDLER;
90 virtual void expunge(
const octopus_entity &
formal(to_zap)) {}
99 class test_octopus_security :
public application_shell
102 test_octopus_security() : application_shell(class_name()) {}
104 virtual int execute();
107 int test_octopus_security::execute()
109 octopus logos(
"local", 18 *
MEGABYTE);
110 simple_tentacle *tenty =
new simple_tentacle;
111 logos.add_tentacle(tenty);
115 simple_entity_registry *guardian =
new simple_entity_registry;
116 logos.add_tentacle(
new login_tentacle(*guardian),
true);
119 octopus_entity jimbo(
"localhost", application_configuration::process_id(), 128, 982938);
120 octopus_request_id req1(jimbo, 1);
123 guardian->add_entity(jimbo, byte_array());
126 simple_infoton testose;
127 simple_infoton *testose_copy =
new simple_infoton(testose);
130 outcome ret = logos.evaluate(testose_copy, req1);
131 if (ret != tentacle::OKAY)
133 astring(
"the operation failed with an error ")
134 + tentacle::outcome_name(ret));
137 octopus_entity burfo(
"localhost", application_configuration::process_id(), 372, 2989);
138 octopus_request_id req2(burfo, 1);
141 testose_copy =
new simple_infoton(testose);
142 ret = logos.evaluate(testose_copy, req2);
143 if (ret == tentacle::OKAY)
145 astring(
"the operation didn't fail when it should have."));
146 else if (ret != tentacle::DISALLOWED)
148 astring(
"the operation didn't provide the proper outcome, it gave: ")
149 + tentacle::outcome_name(ret));
152 guardian->zap_entity(jimbo);
155 testose_copy =
new simple_infoton(testose);
156 ret = logos.evaluate(testose_copy, req1);
157 if (ret == tentacle::OKAY)
159 astring(
"the operation didn't fail when it should have."));
160 else if (ret != tentacle::DISALLOWED)
162 astring(
"the operation didn't provide the proper outcome, it gave: ")
163 + tentacle::outcome_name(ret));
166 guardian->add_entity(burfo, byte_array());
169 testose_copy =
new simple_infoton(testose);
170 ret = logos.evaluate(testose_copy, req2);
171 if (ret != tentacle::OKAY)
173 astring(
"the operation failed with an error ")
174 + tentacle::outcome_name(ret));
176 log(
"octopus:: security works for those functions tested.");
#define deadly_error(c, f, i)
#define formal(parameter)
This macro just eats what it's passed; it marks unused formal parameters.
#define NULL_POINTER
The value representing a pointer to nothing.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
void WHACK(contents *&ptr)
deletion with clearing of the pointer.
const int MEGABYTE
Number of bytes in a megabyte.
bool unpack(basis::byte_array &packed_form, set< contents > &to_unpack)
provides a way to unpack any set that stores packable objects.
void pack(basis::byte_array &packed_form, const set< contents > &to_pack)
provides a way to pack any set that stores packable objects.
int packed_size(const byte_array &packed_form)
Reports the size required to pack a byte array into a byte array.
#define SAFE_STATIC_CONST(type, func_name, parms)
this version returns a constant object instead.
string_array(1, math_list))) const char *addr_list[]