Skip to content

Commit

Permalink
fix authroize, more tests
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.toolserver.org/svnroot/daniel/duesenstuff/trunk/gpClient@567 9f2c43bc-b3c0-43f4-b155-41619b16f219
  • Loading branch information
Daniel Kinzler committed Jan 3, 2012
1 parent 1232411 commit 45d1be4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion php/gpClient.php
Expand Up @@ -1596,7 +1596,7 @@ public static function isValidCommandArgument( $arg, $strict = true ) {
if ( $arg === '' || $arg === false || $arg === null ) return false;

if ( $strict ) return preg_match('/^\w[-\w]*$/', $arg); #TODO: port stricter pattern to python
else return !preg_match('/[\s\0-\x1F\x80-\xFF:|<>!&#]/', $arg); //space, low chars, high chars, and operators. #TODO: port exclusion of spaces to python
else return !preg_match('/[\s\0-\x1F\x80-\xFF|<>!&#]/', $arg); //space, low chars, high chars, and operators. #TODO: port exclusion of spaces and inclusion of colons to python
}

/**
Expand Down
26 changes: 26 additions & 0 deletions php/test/gpCore.test.php
Expand Up @@ -116,10 +116,12 @@ public function testTraverseSuccessorsWithout() {
}

public function testSetMeta() { #TODO: port to python
//define var
$this->gp->set_meta("foo", 1234);
$val = $this->gp->get_meta_value("foo");
$this->assertEquals( "1234", $val );

//redefine var
$this->gp->set_meta("foo", "bla/bla");
$val = $this->gp->get_meta_value("foo");
$this->assertEquals( "bla/bla", $val );
Expand Down Expand Up @@ -162,19 +164,43 @@ public function testSetMeta() { #TODO: port to python
}

public function testGetMeta() { #TODO: port to python
//get undefined
$val = $this->gp->try_get_meta_value("foo");
$this->assertEquals( false, $val );

//set var, and get value
$this->gp->set_meta("foo", "xxx");
$val = $this->gp->get_meta_value("foo");
$this->assertEquals( "xxx", $val );

//remove var, then get value
$this->gp->remove_meta("foo");
$val = $this->gp->try_get_meta_value("foo");
$this->assertEquals( false, $val );
}

public function testRemoveMeta() { #TODO: port to python
//remove undefined
$ok = $this->gp->try_remove_meta("foo");
$this->assertEquals( false, $ok );

//set var, then remove it
$this->gp->set_meta("foo", "xxx");
$ok = $this->gp->try_remove_meta("foo");
$this->assertEquals( "OK", $ok );
}

public function testListMeta() { #TODO: port to python
// assert empty
$meta = $this->gp->capture_list_meta();
$this->assertEmpty( $meta );

// add one, assert list
$this->gp->set_meta("foo", 1234);
$meta = $this->gp->capture_list_meta_map();
$this->assertEquals( array("foo" => "1234"), $meta );

// remove one, assert empty
$this->gp->remove_meta("foo");
$meta = $this->gp->capture_list_meta();
$this->assertEmpty( $meta );
Expand Down
9 changes: 6 additions & 3 deletions php/test/gpSlave.test.php
Expand Up @@ -19,6 +19,12 @@ public function testTry() {
$this->assertEquals( 'FAILED', $this->gp->getStatus() );
}

public function testValue() {
$v = $this->gp->protocol_version_value();

$this->assertTrue( is_numeric($v) );
}

public function testCapture() {
// empty data
$a = $this->gp->capture_list_roots();
Expand Down Expand Up @@ -230,9 +236,6 @@ public function testArgumentValidation() {
$this->assertArgumentRejected( false );
$this->assertArgumentRejected( ' x ' );

//$this->gp->setTimeout(2); // has no effect for pipes
$this->assertArgumentAccepted( 'x:y' ); // needed for password auth! //NOTE: This is broken in graphcore (but works via graphserv)!

$this->assertArgumentAccepted( '123' );
$this->assertArgumentAccepted( 'x' );
$this->assertArgumentAccepted( 'xyz' );
Expand Down

0 comments on commit 45d1be4

Please sign in to comment.