Compare commits
3 Commits
f29af2b664
...
bb738a1d79
| Author | SHA1 | Date | |
|---|---|---|---|
| bb738a1d79 | |||
| fd029a79bf | |||
| 2954d9fc99 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,3 +6,5 @@ cache
|
|||||||
.local
|
.local
|
||||||
*.phar
|
*.phar
|
||||||
.composer
|
.composer
|
||||||
|
.phpunit*
|
||||||
|
.bash_history
|
||||||
File diff suppressed because one or more lines are too long
@@ -59,7 +59,7 @@ class CryptoHelper {
|
|||||||
|
|
||||||
$this->objectRetriever = $objectRetriever;
|
$this->objectRetriever = $objectRetriever;
|
||||||
$this->namespace = isset($namespaceCoid)
|
$this->namespace = isset($namespaceCoid)
|
||||||
? $objectRetriever->getObject($namespaceCoid)
|
? $objectRetriever->getObjectNode($namespaceCoid)
|
||||||
: $objectRetriever->getAuthenticatingNamespaceObject();
|
: $objectRetriever->getAuthenticatingNamespaceObject();
|
||||||
|
|
||||||
$this->reader = new NodeReader([
|
$this->reader = new NodeReader([
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class SharedSecretAuthentication {
|
|||||||
return self::RESULT_INVALID_PASSWORD;
|
return self::RESULT_INVALID_PASSWORD;
|
||||||
|
|
||||||
// Retrieve namespace
|
// Retrieve namespace
|
||||||
$namespace = $retriever->getObject($namespaceCoid);
|
$namespace = $retriever->getObjectNode($namespaceCoid);
|
||||||
if (!isset($namespace))
|
if (!isset($namespace))
|
||||||
return self::RESULT_NAMESPACE_NOT_FOUND;
|
return self::RESULT_NAMESPACE_NOT_FOUND;
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ class SharedSecretAuthentication {
|
|||||||
return self::RESULT_INVALID_PASSWORD;
|
return self::RESULT_INVALID_PASSWORD;
|
||||||
|
|
||||||
// Retrieve namespace
|
// Retrieve namespace
|
||||||
$namespace = $this->objectRetriever->getObject($namespaceCoid);
|
$namespace = $this->objectRetriever->getObjectNode($namespaceCoid);
|
||||||
if (!isset($namespace))
|
if (!isset($namespace))
|
||||||
return self::RESULT_NAMESPACE_NOT_FOUND;
|
return self::RESULT_NAMESPACE_NOT_FOUND;
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class SchemaValidator {
|
|||||||
* @param Node $node The COID of the specification.
|
* @param Node $node The COID of the specification.
|
||||||
*/
|
*/
|
||||||
public function validateAgainstCOID($data, IRI $coid) {
|
public function validateAgainstCOID($data, IRI $coid) {
|
||||||
$object = $this->objectRetriever->getObject($coid);
|
$object = $this->objectRetriever->getObjectNode($coid);
|
||||||
Assert::true($this->reader->hasType($object, 'json:Element'),
|
Assert::true($this->reader->hasType($object, 'json:Element'),
|
||||||
"You can only validate data against JSON elements!");
|
"You can only validate data against JSON elements!");
|
||||||
$this->validateAgainstNode($data, $object);
|
$this->validateAgainstNode($data, $object);
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ class APIClientFactory {
|
|||||||
if ($this->reader->hasProperty($api, 'oauth2:hasAuthorizationServer')) {
|
if ($this->reader->hasProperty($api, 'oauth2:hasAuthorizationServer')) {
|
||||||
// We have an authorization server for this endpoint/API
|
// We have an authorization server for this endpoint/API
|
||||||
$authServerCoid = $this->reader->getFirstValueIRI($api, 'oauth2:hasAuthorizationServer');
|
$authServerCoid = $this->reader->getFirstValueIRI($api, 'oauth2:hasAuthorizationServer');
|
||||||
$authServerObject = $this->objectRetriever->getObject($authServerCoid);
|
$authServerObject = $this->objectRetriever->getObjectNode($authServerCoid);
|
||||||
if (!isset($authServerObject))
|
if (!isset($authServerObject))
|
||||||
throw new InvalidObjectConfigurationException("Authorization server object <"
|
throw new InvalidObjectConfigurationException("Authorization server object <"
|
||||||
. (string)$authServerCoid . "> not available.");
|
. (string)$authServerCoid . "> not available.");
|
||||||
@@ -220,7 +220,7 @@ class APIClientFactory {
|
|||||||
public function __construct(ObjectRetriever $objectRetriever, IRI $namespaceCoid = null) {
|
public function __construct(ObjectRetriever $objectRetriever, IRI $namespaceCoid = null) {
|
||||||
$this->objectRetriever = $objectRetriever;
|
$this->objectRetriever = $objectRetriever;
|
||||||
$this->namespace = isset($namespaceCoid)
|
$this->namespace = isset($namespaceCoid)
|
||||||
? $objectRetriever->getObject($namespaceCoid)
|
? $objectRetriever->getObjectNode($namespaceCoid)
|
||||||
: $objectRetriever->getAuthenticatingNamespaceObject();
|
: $objectRetriever->getAuthenticatingNamespaceObject();
|
||||||
|
|
||||||
$this->reader = new NodeReader([
|
$this->reader = new NodeReader([
|
||||||
@@ -242,7 +242,7 @@ class APIClientFactory {
|
|||||||
public function getClientWithCOID(IRI $apiCoid, bool $specificClient = false) {
|
public function getClientWithCOID(IRI $apiCoid, bool $specificClient = false) {
|
||||||
$idString = (string)$apiCoid.(string)$specificClient;
|
$idString = (string)$apiCoid.(string)$specificClient;
|
||||||
if (!isset($this->apiClients[$idString])) {
|
if (!isset($this->apiClients[$idString])) {
|
||||||
$object = $this->objectRetriever->getObject($apiCoid);
|
$object = $this->objectRetriever->getObjectNode($apiCoid);
|
||||||
if (!isset($object))
|
if (!isset($object))
|
||||||
throw new CoreAPIException("Could not retrieve API <".(string)$apiCoid.">.");
|
throw new CoreAPIException("Could not retrieve API <".(string)$apiCoid.">.");
|
||||||
$this->apiClients[$idString] = $this->createClient($object, $specificClient);
|
$this->apiClients[$idString] = $this->createClient($object, $specificClient);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class NodeReaderMockTest extends \PHPUnit\Framework\TestCase {
|
|||||||
public function testHasType1() {
|
public function testHasType1() {
|
||||||
$coid = new IRI('coid://cloudobjects.io');
|
$coid = new IRI('coid://cloudobjects.io');
|
||||||
$this->useRootResourceMock();
|
$this->useRootResourceMock();
|
||||||
$object = $this->retriever->getObject($coid);
|
$object = $this->retriever->getObjectNode($coid);
|
||||||
|
|
||||||
$this->assertTrue($this->reader->hasType($object, 'coid://cloudobjects.io/Namespace'));
|
$this->assertTrue($this->reader->hasType($object, 'coid://cloudobjects.io/Namespace'));
|
||||||
$this->assertTrue($this->reader->hasType($object, 'co:Namespace'));
|
$this->assertTrue($this->reader->hasType($object, 'co:Namespace'));
|
||||||
@@ -51,7 +51,7 @@ class NodeReaderMockTest extends \PHPUnit\Framework\TestCase {
|
|||||||
public function testHasPropertyValue1() {
|
public function testHasPropertyValue1() {
|
||||||
$coid = new IRI('coid://cloudobjects.io');
|
$coid = new IRI('coid://cloudobjects.io');
|
||||||
$this->useRootResourceMock();
|
$this->useRootResourceMock();
|
||||||
$object = $this->retriever->getObject($coid);
|
$object = $this->retriever->getObjectNode($coid);
|
||||||
|
|
||||||
$this->assertTrue($this->reader->hasPropertyValue($object, 'http://www.w3.org/2000/01/rdf-schema#label', 'CloudObjects'));
|
$this->assertTrue($this->reader->hasPropertyValue($object, 'http://www.w3.org/2000/01/rdf-schema#label', 'CloudObjects'));
|
||||||
$this->assertTrue($this->reader->hasPropertyValue($object, 'rdfs:label', 'CloudObjects'));
|
$this->assertTrue($this->reader->hasPropertyValue($object, 'rdfs:label', 'CloudObjects'));
|
||||||
@@ -60,7 +60,7 @@ class NodeReaderMockTest extends \PHPUnit\Framework\TestCase {
|
|||||||
public function testGetFirstValueString1() {
|
public function testGetFirstValueString1() {
|
||||||
$coid = new IRI('coid://cloudobjects.io');
|
$coid = new IRI('coid://cloudobjects.io');
|
||||||
$this->useRootResourceMock();
|
$this->useRootResourceMock();
|
||||||
$object = $this->retriever->getObject($coid);
|
$object = $this->retriever->getObjectNode($coid);
|
||||||
|
|
||||||
$this->assertEquals('CloudObjects', $this->reader->getFirstValueString($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
|
$this->assertEquals('CloudObjects', $this->reader->getFirstValueString($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
|
||||||
$this->assertEquals('CloudObjects', $this->reader->getFirstValueString($object, 'rdfs:label'));
|
$this->assertEquals('CloudObjects', $this->reader->getFirstValueString($object, 'rdfs:label'));
|
||||||
@@ -75,7 +75,7 @@ class NodeReaderMockTest extends \PHPUnit\Framework\TestCase {
|
|||||||
public function testGetFirstValueIRI1() {
|
public function testGetFirstValueIRI1() {
|
||||||
$coid = new IRI('coid://cloudobjects.io');
|
$coid = new IRI('coid://cloudobjects.io');
|
||||||
$this->useRootResourceMock();
|
$this->useRootResourceMock();
|
||||||
$object = $this->retriever->getObject($coid);
|
$object = $this->retriever->getObjectNode($coid);
|
||||||
|
|
||||||
$this->assertInstanceOf('ML\IRI\IRI', $this->reader->getFirstValueIRI($object, 'coid://cloudobjects.io/isVisibleTo'));
|
$this->assertInstanceOf('ML\IRI\IRI', $this->reader->getFirstValueIRI($object, 'coid://cloudobjects.io/isVisibleTo'));
|
||||||
$this->assertInstanceOf('ML\IRI\IRI', $this->reader->getFirstValueIRI($object, 'co:isVisibleTo'));
|
$this->assertInstanceOf('ML\IRI\IRI', $this->reader->getFirstValueIRI($object, 'co:isVisibleTo'));
|
||||||
@@ -87,7 +87,7 @@ class NodeReaderMockTest extends \PHPUnit\Framework\TestCase {
|
|||||||
public function testGetFirstValueNode1() {
|
public function testGetFirstValueNode1() {
|
||||||
$coid = new IRI('coid://cloudobjects.io');
|
$coid = new IRI('coid://cloudobjects.io');
|
||||||
$this->useRootResourceMock();
|
$this->useRootResourceMock();
|
||||||
$object = $this->retriever->getObject($coid);
|
$object = $this->retriever->getObjectNode($coid);
|
||||||
|
|
||||||
$this->assertInstanceOf('ML\JsonLD\Node', $this->reader->getFirstValueNode($object, 'coid://cloudobjects.io/isVisibleTo'));
|
$this->assertInstanceOf('ML\JsonLD\Node', $this->reader->getFirstValueNode($object, 'coid://cloudobjects.io/isVisibleTo'));
|
||||||
$this->assertInstanceOf('ML\JsonLD\Node', $this->reader->getFirstValueNode($object, 'co:isVisibleTo'));
|
$this->assertInstanceOf('ML\JsonLD\Node', $this->reader->getFirstValueNode($object, 'co:isVisibleTo'));
|
||||||
@@ -99,7 +99,7 @@ class NodeReaderMockTest extends \PHPUnit\Framework\TestCase {
|
|||||||
public function testGetAllValuesString1() {
|
public function testGetAllValuesString1() {
|
||||||
$coid = new IRI('coid://cloudobjects.io');
|
$coid = new IRI('coid://cloudobjects.io');
|
||||||
$this->useRootResourceMock();
|
$this->useRootResourceMock();
|
||||||
$object = $this->retriever->getObject($coid);
|
$object = $this->retriever->getObjectNode($coid);
|
||||||
|
|
||||||
$this->assertCount(1, $this->reader->getAllValuesString($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
|
$this->assertCount(1, $this->reader->getAllValuesString($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
|
||||||
$this->assertCount(1, $this->reader->getAllValuesString($object, 'rdfs:label'));
|
$this->assertCount(1, $this->reader->getAllValuesString($object, 'rdfs:label'));
|
||||||
@@ -116,7 +116,7 @@ class NodeReaderMockTest extends \PHPUnit\Framework\TestCase {
|
|||||||
public function testGetAllValuesIRI1() {
|
public function testGetAllValuesIRI1() {
|
||||||
$coid = new IRI('coid://cloudobjects.io');
|
$coid = new IRI('coid://cloudobjects.io');
|
||||||
$this->useRootResourceMock();
|
$this->useRootResourceMock();
|
||||||
$object = $this->retriever->getObject($coid);
|
$object = $this->retriever->getObjectNode($coid);
|
||||||
|
|
||||||
$this->assertCount(0, $this->reader->getAllValuesIRI($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
|
$this->assertCount(0, $this->reader->getAllValuesIRI($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
|
||||||
$this->assertCount(0, $this->reader->getAllValuesIRI($object, 'rdfs:label'));
|
$this->assertCount(0, $this->reader->getAllValuesIRI($object, 'rdfs:label'));
|
||||||
@@ -136,7 +136,7 @@ class NodeReaderMockTest extends \PHPUnit\Framework\TestCase {
|
|||||||
public function testGetAllValuesNode1() {
|
public function testGetAllValuesNode1() {
|
||||||
$coid = new IRI('coid://cloudobjects.io');
|
$coid = new IRI('coid://cloudobjects.io');
|
||||||
$this->useRootResourceMock();
|
$this->useRootResourceMock();
|
||||||
$object = $this->retriever->getObject($coid);
|
$object = $this->retriever->getObjectNode($coid);
|
||||||
|
|
||||||
$this->assertCount(0, $this->reader->getAllValuesNode($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
|
$this->assertCount(0, $this->reader->getAllValuesNode($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
|
||||||
$this->assertCount(0, $this->reader->getAllValuesNode($object, 'rdfs:label'));
|
$this->assertCount(0, $this->reader->getAllValuesNode($object, 'rdfs:label'));
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class ObjectRetrieverPublicTest extends \PHPUnit\Framework\TestCase {
|
|||||||
|
|
||||||
public function testGetRootObject() {
|
public function testGetRootObject() {
|
||||||
$coid = new IRI('coid://cloudobjects.io');
|
$coid = new IRI('coid://cloudobjects.io');
|
||||||
$object = $this->retriever->getObject($coid);
|
$object = $this->retriever->getObjectNode($coid);
|
||||||
$this->assertNotNull($object);
|
$this->assertNotNull($object);
|
||||||
$this->assertEquals((string)$coid, $object->getID());
|
$this->assertEquals((string)$coid, $object->getID());
|
||||||
$this->assertNotNull($object->getProperty('http://www.w3.org/2000/01/rdf-schema#label'));
|
$this->assertNotNull($object->getProperty('http://www.w3.org/2000/01/rdf-schema#label'));
|
||||||
|
|||||||
Reference in New Issue
Block a user