"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/t/ascii-auth.t" (21 Feb 2022, 1345 Bytes) of package /linux/www/memcached-1.6.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use Test::More tests => 9;
    5 use FindBin qw($Bin);
    6 use lib "$Bin/lib";
    7 use MemcachedTest;
    8 
    9 # FIXME: Some tests are forcing UDP to be enabled via MemcachedTest.pm - need
   10 # to audit and fix.
   11 my $server = new_memcached("-Y $Bin/authfile -U 0");
   12 my $sock = $server->sock;
   13 
   14 # Test unauthenticated modes
   15 print $sock "set foo 0 0 2\r\nhi\r\n";
   16 like(scalar <$sock>, qr/CLIENT_ERROR/, "failed to do a write");
   17 print $sock "get foo\r\n";
   18 like(scalar <$sock>, qr/CLIENT_ERROR/, "failed to do a read");
   19 
   20 # Fail to authenticate.
   21 print $sock "set foo 0 0 7\r\nfoo bab\r\n";
   22 like(scalar <$sock>, qr/CLIENT_ERROR/, "failed to authenticate");
   23 
   24 # Try for real.
   25 print $sock "set foo 0 0 7\r\nfoo bar\r\n";
   26 like(scalar <$sock>, qr/STORED/, "authenticated?");
   27 
   28 print $sock "set toast 0 0 2\r\nhi\r\n";
   29 like(scalar <$sock>, qr/STORED/, "stored an item that didn't look like user/pass");
   30 
   31 mem_get_is($sock, "toast", "hi");
   32 
   33 # Create a second socket, try to authenticate against the second token.
   34 
   35 my $sock2 = $server->new_sock;
   36 
   37 print $sock2 "set foo 0 0 10\r\nbaaaz quux\r\n";
   38 like(scalar <$sock2>, qr/STORED/, "authenticated a second socket?");
   39 
   40 print $sock2 "set toast2 0 0 2\r\nho\r\n";
   41 like(scalar <$sock2>, qr/STORED/, "stored an item that didn't look like user/pass");
   42 
   43 mem_get_is($sock2, "toast2", "ho");
   44 
   45 # TODO: tests for reloads.