Example #1
0
 /**
  *
  * Process HTTP POST request on licenses
  *
  *    licenses           
  *
  * @param array $segments
  * @param array $data
  */
 private function POST_licenses($segments, $data)
 {
     /*
      * No modifier allowed
      */
     if (isset($segments[1])) {
         RestoLogUtil::httpError(404);
     }
     if (!isset($data['licenseId'])) {
         RestoLogUtil::httpError(400, 'license Identifier is not set');
     }
     $license = new RestoLicense($this->context, $data['licenseId'], false);
     $license->setDescription($data);
     return RestoLogUtil::success('license ' . $data['licenseId'] . ' created');
 }
Example #2
0
 /**
  * @depends testGetCollection
  */
 public function testRegisteredUser()
 {
     $this->initContext();
     $profile = array('userid' => 2, 'groups' => 'default', 'email' => 'test_email', 'password' => 'test_password', 'username' => 'test_username', 'givenname' => 'test_givenname', 'lastname' => 'test_lastname', 'country' => 'FR', 'organization' => 'test_organization', 'flags' => null, 'topics' => null, 'validatedby' => 'admin', 'validationdate' => 'now()', 'activated' => 1);
     $user = new RestoUser($profile, $this->context);
     $this->assertEquals(false, $user->isAdmin());
     $this->assertEquals(true, $user->isValidated());
     $this->assertEquals(false, $user->hasRightsTo('create'));
     $this->assertEquals(true, $user->hasRightsTo('download', array('collectionName' => 'Landsat')));
     $this->assertEquals(false, $user->hasRightsTo('update', array('collectionName' => 'Landsat')));
     $this->assertEquals(true, $user->hasRightsTo('visualize', array('collectionName' => 'Landsat')));
     $license = new RestoLicense($this->context, 'Example', true);
     $this->assertEquals(true, $license->isApplicableToUser($user));
     /*
      * Test when user has not signed license
      */
     $this->assertEquals(true, $license->hasToBeSignedByUser($user));
     /*
      * Sign license
      */
     $user->signLicense($license);
     $signatures = $user->getSignatures();
     $this->assertEquals(false, empty($signatures));
     /*
      * Test when user has signed license
      */
     $this->assertEquals(false, $license->hasToBeSignedByUser($user));
     $this->assertEquals(false, $user->activate());
     $this->assertEquals(true, array_key_exists('token', $user->connect()));
     $this->assertEquals(true, $user->disconnect());
     $_aa = $this->admin->addGroups('toto');
     $_rr = $this->admin->removeGroups('toto');
     $this->assertEquals('success', $_aa['status']);
     $this->assertEquals('success', $_rr['status']);
 }