--- /dev/null
+#!/usr/bin/perl
+
+use Test::More tests => 17;
+
+BEGIN { use_ok('Net::Cmd') }
+BEGIN { use_ok('Net::NNTP') }
+
+my $c = Net::NNTP->new(Host => '127.0.0.1', Port => 20203, Reader => 0);
+
+ok(defined $c, 'connected to localhost');
+
+BAIL_OUT(q{can't connect to test server'}) unless $c;
+
+sub Net::NNTP::issue {
+ my ($c, @cmd) = @_;
+ $c->command(@cmd);
+ $c->response();
+ return $c->code();
+}
+
+sub Net::NNTP::try {
+ my ($c, $cmd, $test, @valid) = @_;
+ $c->command($cmd);
+ $c->response();
+ ok(scalar (grep {$c->code == $_} @valid) , "$test ".$c->code." in (@valid)");
+ return $c->code;
+}
+
+# 3977:5.1.1 initial greeting must be 200 201 400 502
+my @valid = (200, 201, 400, 502);
+my $greeting = $c->code;
+
+ok(grep {$c->code == $_} @valid, 'correct initial response from server');
+
+unless ($greeting == 200 or $greeting = 201) {
+ BAIL_OUT(q{bad greeting from server'});
+}
+
+# 4 tests done to here
+
+$c->try('CAPABILITIES','capabilities',101);
+
+SKIP: {
+ skip q{can't get capabilities}, 3 unless $c->code == 101;
+
+ my $capabilities = $c->read_until_dot() if ($c->code == 101);
+
+ my %cap = ();
+ my $twice = 0;
+ foreach my $line (@$capabilities) {
+ my ($capability, @arg) = split(/\s+/, $line);
+ if (exists($cap{$capability})) {
+ $twice = 1;
+ }
+ $cap{$capability} = \@arg;
+ }
+
+ ok($twice == 0, 'No capability listed twice (3977:5.2.2)');
+ ok(exists $cap{READER}, 'announce READER');
+ is($cap{'MODE-READER'}, undef, q{don't announce MODE-READER});
+ foreach $trycap qw(ACTIVE NEWSGROUPS OVERVIEW.FMT
+ ACTIVE.TIMES HEADERS) {
+ cmp_ok(scalar(grep { $trycap eq $_ } @{$cap{LIST}}), '==', 1,
+ "list capability $trycap");
+ }
+ foreach $trycap qw(MSGID) {
+ cmp_ok(scalar(grep { $trycap eq $_ } @{$cap{OVER}}), '==', 1,
+ "list capability $trycap");
+ }
+
+ $capabilities->[0] =~ /(VERSION) (\d+)(\r?)(\n)/;
+
+ is($1, 'VERSION', 'VERSION capability first');
+ is($2, 2, 'Version 2 server');
+ skip q{can only test version 2 servers}, 0 unless $2 == 2;
+
+}
+
+$c->try('QUIT','quit',205);