PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / microsoft / microsoft-graph / tests / Functional / GraphTestBase.php
ameliabooking / vendor / microsoft / microsoft-graph / tests / Functional Last commit date
Resources 5 years ago AzureTest.php 1 year ago ContactTest.php 5 years ago DeltaQueryTest.php 1 year ago EventTest.php 5 years ago ExcelTest.php 1 year ago GraphTestBase.php 1 year ago MailTest.php 1 year ago OnedriveTest.php 1 year ago OnenoteTest.php 1 year ago OpenTypeTest.php 1 year ago PlannerTest.php 1 year ago SharepointTest.php 1 year ago TermStoreTest.php 1 year ago TestConstants.php 1 year ago UserTest.php 1 year ago WebhooksTest.php 1 year ago
GraphTestBase.php
90 lines
1 <?php
2 /**
3 * Copyright (c) Microsoft Corporation. All Rights Reserved.
4 * Licensed under the MIT License. See License in the project root
5 * for license information.
6 *
7 * GraphTestBase File
8 * PHP version 7
9 *
10 * @category Library
11 * @package Microsoft.Graph
12 * @copyright 2020 Microsoft Corporation
13 * @license https://opensource.org/licenses/MIT MIT License
14 * @link https://https://developer.microsoft.com/en-us/graph
15 */
16
17 namespace Microsoft\Graph\Test;
18
19 use Microsoft\Graph\Graph;
20 include_once("TestConstants.php");
21
22 /**
23 * Base class for tests that will perform E2E against a live tenant using
24 * the client credential OAuth2 flow.
25 * Prerequisites:
26 * 1) An app registration in the https://portal.azure.com with a generated client secret.
27 * 2) Capture the Application ID (client ID), client secret, and tenant ID from
28 * the app registration.
29 * 3) Set them in environment variables in your dev and/or CI pipeline in the
30 * following variables: client_id, test_tenantId, test_secret
31 */
32 class GraphTestBase
33 {
34 private $clientId;
35
36 private $scopes = "https://graph.microsoft.com/.default";
37 private $contentType = "application/x-www-form-urlencoded";
38 private $grantType = "client_credentials";
39 private $tenantId;
40 private $clientSecret;
41 private $endpoint;
42 public $graphClient;
43 public $user;
44
45 public function __construct()
46 {
47 $this->clientId = CLIENT_ID;
48 $this->clientSecret = CLIENT_SECRET;
49 $this->tenantId = TENANT_ID;
50 $this->endpoint = "https://login.microsoftonline.com/{$this->tenantId}/oauth2/v2.0/token";
51 $this->user = TEST_USER_UPN;
52
53 $this->getAuthenticatedClient();
54 }
55
56 public function getAuthenticatedClient()
57 {
58 if ($this->graphClient == null)
59 {
60 $this->graphClient = new Graph();
61 $this->graphClient->setAccessToken($this->getAccessToken());
62 // $this->graphClient->setProxyPort("localhost:8888"); // Need for fiddler.
63 }
64 }
65
66 public function getAccessToken()
67 {
68 $body = "grant_type=".$this->grantType
69 ."&client_info=1"
70 ."&client_id=".$this->clientId
71 ."&scope=".$this->scopes
72 ."&client_secret=".$this->clientSecret;
73 $ch = curl_init();
74 curl_setopt($ch, CURLOPT_URL, $this->endpoint);
75 curl_setopt($ch, CURLOPT_POST, 1);
76 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
77 curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
78 curl_setopt($ch, CURLOPT_FAILONERROR, 0);
79 // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // turns off SSL check,
80 // curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1:8888"); // need for fiddler + auth
81 curl_setopt($ch, CURLOPT_HTTPHEADER, array($this->contentType, 'Content-Length: ' . strlen($body)));
82
83 $result = curl_exec ($ch);
84 $token = json_decode($result, true)['access_token'];
85 curl_close($ch);
86
87 return $token;
88 }
89 }
90