Exemplo n.º 1
0
 /**
  * Initializes the Test Suite
  */
 public function setUp()
 {
     $this->config = array('environment' => 'production', 'app' => array('host' => "https://mysuperapp.com"), 'api' => array('id' => "myappid", 'key' => "myappkey", 'group_id' => "mygroupid", 'host' => 'https://someapihost.com'), 'sso' => array('init_path' => "/mno/init_path.php", 'consume_path' => "/mno/consume_path.php", 'idp' => "https://mysuperidp.com", 'idm' => "https://mysuperidm.com", 'x509_fingerprint' => "some-x509_fingerprint", 'x509_certificate' => "some-x509_certificate"), 'connec' => array('enabled' => true, 'host' => 'http://connec.maestrano.io', 'base_path' => '/api', 'v2_path' => '/v2', 'reports_path' => '/reports'), 'webhook' => array('account' => array('groups_path' => "/mno/groups/:id", 'group_users_path' => "/mno/groups/:group_id/users/:id"), 'connec' => array('enabled' => true, 'initialization_path' => "/mno/connec/initialization", 'notifications_path' => "/mno/connec/notifications", 'subscriptions' => array('organizations' => true, 'people' => true))));
     $preset = 'some-marketplace';
     Maestrano::with($preset)->configure($this->config);
     $this->ssoService = Maestrano::ssoWithPreset($preset);
 }
Exemplo n.º 2
0
 /**
  * Configure Maestrano presets with fetched marketplaces
  *
  * @param $conf_array array Array containing the environments to load
  */
 public static function loadMultipleMarketplaces($conf_array)
 {
     // Load every environments
     foreach ($conf_array as $marketplace) {
         Maestrano::with($marketplace['marketplace'])->configure($marketplace);
     }
 }
Exemplo n.º 3
0
 public static function newWithPreset($preset, $saml_response, $settings = null)
 {
     if ($settings == null) {
         $settings = Maestrano::with($preset)->sso()->getSamlSettings();
     }
     return new Maestrano_Saml_Response($get_params, $settings);
 }
Exemplo n.º 4
0
 public function getGroupId()
 {
     if (!is_null($this->group_id)) {
         return $this->group_id;
     } else {
         return Maestrano::with($this->_preset)->param('api.group_id');
     }
 }
Exemplo n.º 5
0
 /**
  * Return a json string describing the configuration
  * currently used by the PHP bindings
  */
 public static function toMetadataWithPreset($preset)
 {
     $config = array('environment' => Maestrano::with($preset)->param('environment'), 'app' => array('host' => Maestrano::with($preset)->param('app.host')), 'api' => array('id' => Maestrano::with($preset)->param('api.id'), 'version' => Maestrano::with($preset)->param('api.version'), 'verify_ssl_certs' => false, 'lang' => Maestrano::with($preset)->param('api.lang'), 'lang_version' => Maestrano::with($preset)->param('api.lang_version'), 'host' => Maestrano::with($preset)->param('api.host'), 'base' => Maestrano::with($preset)->param('api.base')), 'sso' => array('enabled' => Maestrano::with($preset)->param('sso.enabled'), 'slo_enabled' => Maestrano::with($preset)->param('sso.slo_enabled'), 'init_path' => Maestrano::with($preset)->param('sso.init_path'), 'consume_path' => Maestrano::with($preset)->param('sso.consume_path'), 'creation_mode' => Maestrano::with($preset)->param('sso.creation_mode'), 'idm' => Maestrano::with($preset)->param('sso.idm'), 'idp' => Maestrano::with($preset)->param('sso.idp'), 'name_id_format' => Maestrano::with($preset)->param('sso.name_id_format'), 'x509_fingerprint' => Maestrano::with($preset)->param('sso.x509_fingerprint'), 'x509_certificate' => Maestrano::with($preset)->param('sso.x509_certificate')), 'connec' => array('enabled' => Maestrano::with($preset)->param('connec.enabled'), 'host' => Maestrano::with($preset)->param('connec.host'), 'base_path' => Maestrano::with($preset)->param('connec.base_path'), 'v2_path' => Maestrano::with($preset)->param('connec.v2_path'), 'reports_path' => Maestrano::with($preset)->param('connec.reports_path')), 'webhook' => array('account' => array('groups_path' => Maestrano::with($preset)->param('webhook.account.groups_path'), 'group_users_path' => Maestrano::with($preset)->param('webhook.account.group_users_path')), 'connec' => array('initialization_path' => Maestrano::with($preset)->param('webhook.connec.initialization_path'), 'notifications_path' => Maestrano::with($preset)->param('webhook.connec.notifications_path'), 'subscriptions' => Maestrano::with($preset)->param('webhook.connec.subscriptions'))));
     return json_encode($config);
 }
 /**
  * Initializes the Test Suite
  */
 public function setUp()
 {
     Maestrano::with('some-preset')->configure(array('environment' => 'test', 'api' => array('id' => 'app-1', 'key' => 'gfcmbu8269wyi0hjazk4t7o1sndpvrqxl53e1')));
 }
Exemplo n.º 7
0
 /**
  * Return a settings object for php-saml
  *
  * @return Maestrano_Saml_Settings
  */
 public function getSamlSettings()
 {
     $settings = new Maestrano_Saml_Settings();
     // Configure SAML
     $settings->idpPublicCertificate = Maestrano::with($this->_preset)->param('sso.x509_certificate');
     $settings->spIssuer = Maestrano::with($this->_preset)->param('api.id');
     $settings->requestedNameIdFormat = Maestrano::with($this->_preset)->param('sso.name_id_format');
     $settings->idpSingleSignOnUrl = $this->getIdpUrl();
     $settings->spReturnUrl = $this->getConsumeUrl();
     return $settings;
 }
Exemplo n.º 8
0
 /**
  * Perform check to see if session is valid
  * Check is only performed if current time is after
  * the recheck timestamp
  * If a remote check is performed then the mno_session_recheck
  * timestamp is updated in session.
  *
  * @return boolean the validity of the session
  */
 public function isValid($ifSession = false, $httpClient = null)
 {
     $svc = Maestrano::with($this->_preset)->sso();
     if (!$svc->isSloEnabled()) {
         return true;
     }
     if ($ifSession) {
         return true;
     }
     if (!$this->ssoTokenExists() || $this->isRemoteCheckRequired()) {
         if ($this->performRemoteCheck($httpClient)) {
             $this->save();
             return true;
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
 public function testLoadMultipleMarketplaces()
 {
     $fromServer = json_decode('[
         {
           "marketplace": "maestrano-uat",
           "environment": "local",
           "app": {
             "host": "http://php-demoapp.maestrano.io"
           },
           "api": {
             "id": "e30ac587-54ee-429d-92ff-66efdd1abf32",
             "key": "6z3KsJaDfyFZ3VNTxIVzEg"
           }
         },
         {
           "marketplace": "maestrano-prod",
           "environment": "local",
           "app": {
             "host": "http://php-demoapp.maestrano.io"
           },
           "api": {
             "id": "e30ac587-54ee-429d-92ff-66efdd1abf32",
             "key": "6z3KsJaDfyFZ3VNTxIVzEg"
           }
         }
       ]', true);
     Maestrano_Config_Client::loadMultipleMarketplaces($fromServer);
     $this->assertEquals(Maestrano::with('maestrano-uat')->param('environment'), 'local');
     $this->assertEquals(Maestrano::with('maestrano-prod')->param('environment'), 'local');
 }
Exemplo n.º 10
0
 /**
  * @param number $errno
  * @param string $message
  * @throws Maestrano_Api_ConnectionError
  */
 public function handleCurlError($errno, $message)
 {
     $apiBase = Maestrano::with($this->_preset)->param('api.host');
     switch ($errno) {
         case CURLE_COULDNT_CONNECT:
         case CURLE_COULDNT_RESOLVE_HOST:
         case CURLE_OPERATION_TIMEOUTED:
             $msg = "Could not connect to Maestrano ({$apiBase}).  Please check your " . "internet connection and try again.  If this problem persists, " . "you should check Maestrano's service status at " . "https://twitter.com/Maestrano, or";
             break;
         case CURLE_SSL_CACERT:
         case CURLE_SSL_PEER_CERTIFICATE:
             $msg = "Could not verify Maestrano's SSL certificate.  Please make sure " . "that your network is not intercepting certificates.  " . "(Try going to {$apiBase} in your browser.)  " . "If this problem persists,";
             break;
         default:
             $msg = "Unexpected error communicating with Maestrano.  " . "If this problem persists,";
     }
     $msg .= " let us know at support@Maestrano.com.";
     $msg .= "\n\n(Network error [errno {$errno}]: {$message})";
     throw new Maestrano_Api_ConnectionError($msg);
 }
Exemplo n.º 11
0
 public function testBindingConfigurationWithPreset()
 {
     $preset = 'some-marketplace';
     Maestrano::with($preset)->configure($this->config);
     $this->assertEquals($this->config['environment'], Maestrano::with($preset)->param('environment'));
     $this->assertEquals($this->config['app']['host'], Maestrano::with($preset)->param('app.host'));
     $this->assertEquals($this->config['api']['id'], Maestrano::with($preset)->param('api.id'));
     $this->assertEquals($this->config['api']['key'], Maestrano::with($preset)->param('api.key'));
     $this->assertEquals($this->config['api']['group_id'], Maestrano::with($preset)->param('api.group_id'));
     $this->assertEquals($this->config['api']['host'], Maestrano::with($preset)->param('api.host'));
     $this->assertEquals($this->config['sso']['init_path'], Maestrano::with($preset)->param('sso.init_path'));
     $this->assertEquals($this->config['sso']['consume_path'], Maestrano::with($preset)->param('sso.consume_path'));
     $this->assertEquals($this->config['sso']['idp'], Maestrano::with($preset)->param('sso.idp'));
     $this->assertEquals($this->config['sso']['x509_fingerprint'], Maestrano::with($preset)->param('sso.x509_fingerprint'));
     $this->assertEquals($this->config['sso']['x509_certificate'], Maestrano::with($preset)->param('sso.x509_certificate'));
     $this->assertEquals($this->config['connec']['enabled'], Maestrano::with($preset)->param('connec.enabled'));
     $this->assertEquals($this->config['connec']['host'], Maestrano::with($preset)->param('connec.host'));
     $this->assertEquals($this->config['connec']['base_path'], Maestrano::with($preset)->param('connec.base_path'));
     $this->assertEquals($this->config['connec']['v2_path'], Maestrano::with($preset)->param('connec.v2_path'));
     $this->assertEquals($this->config['connec']['reports_path'], Maestrano::with($preset)->param('connec.reports_path'));
     $this->assertEquals($this->config['webhook']['account']['groups_path'], Maestrano::with($preset)->param('webhook.account.groups_path'));
     $this->assertEquals($this->config['webhook']['account']['group_users_path'], Maestrano::with($preset)->param('webhook.account.group_users_path'));
     $this->assertEquals($this->config['webhook']['connec']['initialization_path'], Maestrano::with($preset)->param('webhook.connec.initialization_path'));
     $this->assertEquals($this->config['webhook']['connec']['notifications_path'], Maestrano::with($preset)->param('webhook.connec.notifications_path'));
     $this->assertEquals($this->config['webhook']['connec']['subscriptions'], Maestrano::with($preset)->param('webhook.connec.subscriptions'));
 }