Skip to content

Commit 45d1be4

Browse files
author
Daniel Kinzler
committed
fix authroize, more tests
git-svn-id: https://svn.toolserver.org/svnroot/daniel/duesenstuff/trunk/gpClient@567 9f2c43bc-b3c0-43f4-b155-41619b16f219
1 parent 1232411 commit 45d1be4

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

php/gpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ public static function isValidCommandArgument( $arg, $strict = true ) {
15961596
if ( $arg === '' || $arg === false || $arg === null ) return false;
15971597

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

16021602
/**

php/test/gpCore.test.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ public function testTraverseSuccessorsWithout() {
116116
}
117117

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

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

164166
public function testGetMeta() { #TODO: port to python
167+
//get undefined
168+
$val = $this->gp->try_get_meta_value("foo");
169+
$this->assertEquals( false, $val );
170+
171+
//set var, and get value
172+
$this->gp->set_meta("foo", "xxx");
173+
$val = $this->gp->get_meta_value("foo");
174+
$this->assertEquals( "xxx", $val );
175+
176+
//remove var, then get value
177+
$this->gp->remove_meta("foo");
178+
$val = $this->gp->try_get_meta_value("foo");
179+
$this->assertEquals( false, $val );
165180
}
166181

167182
public function testRemoveMeta() { #TODO: port to python
183+
//remove undefined
184+
$ok = $this->gp->try_remove_meta("foo");
185+
$this->assertEquals( false, $ok );
186+
187+
//set var, then remove it
188+
$this->gp->set_meta("foo", "xxx");
189+
$ok = $this->gp->try_remove_meta("foo");
190+
$this->assertEquals( "OK", $ok );
168191
}
169192

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

198+
// add one, assert list
174199
$this->gp->set_meta("foo", 1234);
175200
$meta = $this->gp->capture_list_meta_map();
176201
$this->assertEquals( array("foo" => "1234"), $meta );
177202

203+
// remove one, assert empty
178204
$this->gp->remove_meta("foo");
179205
$meta = $this->gp->capture_list_meta();
180206
$this->assertEmpty( $meta );

php/test/gpSlave.test.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ public function testTry() {
1919
$this->assertEquals( 'FAILED', $this->gp->getStatus() );
2020
}
2121

22+
public function testValue() {
23+
$v = $this->gp->protocol_version_value();
24+
25+
$this->assertTrue( is_numeric($v) );
26+
}
27+
2228
public function testCapture() {
2329
// empty data
2430
$a = $this->gp->capture_list_roots();
@@ -230,9 +236,6 @@ public function testArgumentValidation() {
230236
$this->assertArgumentRejected( false );
231237
$this->assertArgumentRejected( ' x ' );
232238

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

0 commit comments

Comments
 (0)