Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 76 lines (60 sloc) 2.542 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
# tests/test_selfreg
#
# Part of the CCNx distribution.
#
# Copyright (C) 2009 Palo Alto Research Center, Inc.
#
# This work is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License version 2 as published by the
# Free Software Foundation.
# This work is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.
#
AFTER : test_single_ccnd test_ccndid
BEFORE : test_single_ccnd_teardown

ccndsmoketest || SkipTest no ccnd
test -f newface-response.ccnb || SkipTest missing newface-response.ccnb, need to run test_newface first

# Create the body of a selfreg request.
ccn_xmltoccnb -w - <<EOF >selfreg.ccnb
<ForwardingEntry>
  <Action>selfreg</Action>
  <Name>
     <Component ccnbencoding="text">Junk</Component>
     <Component ccnbencoding="text">Testing</Component>
     <Component ccnbencoding="text">Selfreg</Component>
  </Name>
  <FreshnessSeconds>19</FreshnessSeconds>
</ForwardingEntry>
EOF

TNAME=`GenSym SR`
cat selfreg.ccnb | ccnpoke -f -x 30 /$TNAME

# Pull it out to use in the selfreg request. Base-64 encode it for the benefit of the shell.

SRBLOB="`ccnpeek /$TNAME | openssl enc -base64`"

echo SRBLOB is $SRBLOB >&2

# We have the CCNDID of our ccnd in a file, left from test_ccndid
CCNDID=`cat ccndid.out`

# Now construct the interest.

cat <<EOF >selfreg-request.xml
<Interest>
  <Name>
    <Component ccnbencoding="text">ccnx</Component>
    <Component ccnbencoding="hexBinary">$CCNDID</Component>
    <Component ccnbencoding="text">selfreg</Component>
    <Component ccnbencoding="base64Binary">$SRBLOB</Component>
  </Name>
  <Scope>1</Scope>
</Interest>
EOF
ccn_xmltoccnb -w selfreg-request.xml || Fail botch constructing selfreg-request.ccnb

CCNDStatus > selfreg-pre.html

# Try out the request; use udp so our face does not instantly vanish
# Send a heartbeat first to convince ccnd to trust us to selfreg
dd if=/dev/zero bs=1 count=1 > heartbeat.ccnb
ccndsmoketest -u localhost -b send heartbeat.ccnb send selfreg-request.ccnb recv > selfreg-response.ccnb

cmp -s /dev/null selfreg-response.ccnb && Fail did not get selfreg response
ccn_ccnbtoxml selfreg-response.ccnb || Failed to parse selfreg response

ccnbx -d selfreg-response.ccnb Content | ccn_ccnbtoxml -x -

CCNDStatus > selfreg-post.html
grep ccnx:/Junk/Testing/Selfreg selfreg-post.html >/dev/null || Fail Self-registered prefix does not show up in ccnd status

rm selfreg-request.xml
Something went wrong with that request. Please try again.