IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23852


Ignore:
Timestamp:
Apr 14, 2009, 10:50:32 AM (17 years ago)
Author:
jhoblitt
Message:

Nebulous::Key parsing and testing improvements

Location:
branches/neb_distrib_20081210/Nebulous-Server
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/neb_distrib_20081210/Nebulous-Server/Changes

    r23755 r23852  
    1313      hash of a key to change
    1414    - create a pseduo directory structure on key creation
     15    - Nebulous::Key parsing and testing improvements
    1516     
    16170.16
  • branches/neb_distrib_20081210/Nebulous-Server/lib/Nebulous/Key.pm

    r23715 r23852  
    5454        # strip off volume component if it exists
    5555        $path =~ s|^//([^/]+)||;
     56
     57        # a new is not allowed to be just a volume specifier, it must have a
     58        # path component to it
     59        unless (length $path) {
     60            die "neb URI scheme requires a path component";
     61        }
    5662       
    5763        # ignore key supplied volume name if one is passed as a parameter
     
    8187    # strip leading slashes
    8288    $path =~ s|^/+||;
     89
     90    # strip leading '.' or '..'
     91    $path =~ s|^\.{1,2}||;
    8392
    8493    # remove multiple /'s and trailing slashes
     
    92101}
    93102
     103
    94104sub parse_neb_volume
    95105{
     
    106116}
    107117
     118
    108119sub _stringify_key
    109120{
     
    116127    return "neb://${soft_volume}${volume}/$path";
    117128}
     129
    118130
    1191311;
  • branches/neb_distrib_20081210/Nebulous-Server/t/75_parse_neb_key.t

    r23754 r23852  
    1010use Test::More;
    1111
    12 plan tests => 80;
     12plan tests => 99;
    1313
    1414use lib qw( ./t ./lib );
     
    224224}
    225225
     226# root volume references
     227{
     228    my $key = parse_neb_key('neb:///');
     229
     230    is($key->path, '', 'path');
     231    is($key->volume, undef, 'volume name');
     232    is($key->soft_volume, undef, 'soft volume name');
     233}
     234
     235{
     236    my $key = parse_neb_key('neb:///.');
     237
     238    is($key->path, '', 'path');
     239    is($key->volume, undef, 'volume name');
     240    is($key->soft_volume, undef, 'soft volume name');
     241}
     242
     243{
     244    my $key = parse_neb_key('neb:///..');
     245
     246    is($key->path, '', 'path');
     247    is($key->volume, undef, 'volume name');
     248    is($key->soft_volume, undef, 'soft volume name');
     249}
     250
     251{
     252    my $key = parse_neb_key('/');
     253
     254    is($key->path, '', 'path');
     255    is($key->volume, undef, 'volume name');
     256    is($key->soft_volume, undef, 'soft volume name');
     257}
     258
     259{
     260    my $key = parse_neb_key('.');
     261
     262    is($key->path, '', 'path');
     263    is($key->volume, undef, 'volume name');
     264    is($key->soft_volume, undef, 'soft volume name');
     265}
     266
     267{
     268    my $key = parse_neb_key('..');
     269
     270    is($key->path, '', 'path');
     271    is($key->volume, undef, 'volume name');
     272    is($key->soft_volume, undef, 'soft volume name');
     273}
     274
    226275# key w/ whitespace
    227276eval {
     
    267316};
    268317like( $@, qr/requires a leading slash/, "leading slash" );
     318
     319# URI w/ volume but w/o path
     320eval {
     321    my $key = parse_neb_key('neb://foo');
     322};
     323like( $@, qr/requires a path/, "no path" );
Note: See TracChangeset for help on using the changeset viewer.