1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353 |
- <?php
- /*
- * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * Http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
- include 'BaiduBce.phar';
- require 'CdnSampleConf.php';
- use BaiduBce\Services\Cdn\CdnClient;
- use BaiduBce\BceClientConfigOptions;
- use BaiduBce\Log\LogFactory;
- class CdnClientTest extends PHPUnit_Framework_TestCase
- {
- public function __construct()
- {
- global $g_CDN_TEST_CONFIG;
- parent::__construct();
- $this->client = new CdnClient($g_CDN_TEST_CONFIG);
- $this->logger = LogFactory::getLogger(get_class($this));
- }
- /**
- * test create domain
- */
- public static function setUpBeforeClass()
- {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $origins = array(
- array("peer" => "test.origin.domain.com"),
- );
- $client->createDomain($domain, $origins);
- }
- /**
- * test delete domain
- */
- public static function tearDownAfterClass()
- {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $client->deleteDomain($domain);
- }
- /**
- * test list domain
- */
- public function testListDomain()
- {
- $resp = $this->client->listDomains();
- $this->assertNotNull($resp);
- }
- /**
- * test valid domain
- */
- public function testValidDomain() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->validDomain($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test list user domains
- */
- public function testListUserDomains() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $status = "RUNNING";
- $rule = "www";
- $param = array(
- 'status' => $status,
- 'rule' => $rule
- );
- $resp = $client->listUserDomains($param);
- $this->assertNotNull($resp);
- }
- /**
- * test valid domain
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testValidDomainThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $resp = $client->validDomain($domain);
- }
- /**
- * test start domain
- */
- public function testEnableDomain()
- {
- $domain = "test-sdk.sys-qa.com";
- $resp = $this->client->enableDomain($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test stop domain
- */
- public function testDisableDomain()
- {
- $domain = "test-sdk.sys-qa.com";
- $resp = $this->client->disableDomain($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test update domain origin address
- */
- public function testSetDomainOrigin()
- {
- $domain = "test-sdk.sys-qa.com";
- $origins = array(
- array(
- "peer" => "test.origin-new.domain.com",
- 'host' => 'www.origin-host.com'
- ),
- );
- $resp = $this->client->setDomainOrigin($domain, $origins);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain config
- */
- public function testGetDomainConfig()
- {
- $domain = "test-sdk.sys-qa.com";
- $resp = $this->client->getDomainConfig($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain cacheFullUrl
- */
- public function testGetDomainCacheFullUrl() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainCacheFullUrl($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain cacheFullUrl
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainCacheFullUrlThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $resp = $client->getDomainCacheFullUrl($domain);
- }
- /**
- * test set domain errorPage
- */
- public function testSetDomainErrorPage() {
- global $g_CDN_TEST_CONFIG;
- $errorPage = array(
- 'errorPage' => array(
- array(
- 'code' => 404,
- "redirectCode" => 302,
- "url" => "customer_404.html"
- ),
- array(
- 'code' => 403,
- "url" => "customer_403.html"
- )
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainErrorPage($domain, $errorPage);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain errorPage
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainErrorPageThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $errorPage = array();
- $resp = $client->setDomainErrorPage($domain, $errorPage);
- }
- /**
- * test get domain errorPage
- */
- public function testGetDomainErrorPage() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainErrorPage($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain errorPage
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainErrorPageThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $resp = $client->getDomainErrorPage($domain);
- }
- /**
- * test set domain requestAuth
- */
- public function testSetDomainRequestAuth() {
- global $g_CDN_TEST_CONFIG;
- $requestAuth = array(
- 'requestAuth' => array(
- "type" => "c",
- "key1" => "secretekey1",
- "key2" => "secretekey2",
- "timeout" => 300,
- "whiteList" => array("/crossdomain.xml"),
- "signArg" => "sign",
- "timeArg" => "t"
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainRequestAuth($domain, $requestAuth);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain requestAuth
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainRequestAuthThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $requestAuth = array();
- $client->setDomainRequestAuth($domain, $requestAuth);
- }
- /**
- * test set domain cors
- */
- public function testSetDomainCors() {
- global $g_CDN_TEST_CONFIG;
- $cors = array(
- 'cors' => array(
- "allow" => "on",
- 'originList' => array(
- "www.baidu.com",
- )
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainCors($domain, $cors);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain cors
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainCorsThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $cors = array();
- $client->setDomainCors($domain, $cors);
- }
- /**
- * test get domain cors
- */
- public function testGetDomainCors() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainCors($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain cors
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainCorsThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $client->getDomainCors($domain);
- }
- /**
- * test set domain accessLimit
- */
- public function testSetDomainAccessLimit() {
- global $g_CDN_TEST_CONFIG;
- $accessLimit = array(
- 'accessLimit' => array(
- "enabled" => true,
- "limit" => 200
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainAccessLimit($domain, $accessLimit);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain accessLimit
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainAccessLimitThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $accessLimit = array();
- $client->setDomainAccessLimit($domain, $accessLimit);
- }
- /**
- * test get domain accessLimit
- */
- public function testGetDomainAccessLimit() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainAccessLimit($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain accessLimit
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainAccessLimitThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $client->getDomainAccessLimit($domain);
- }
- /**
- * test set domain clientIp
- */
- public function testSetDomainClientIp() {
- global $g_CDN_TEST_CONFIG;
- $clientIp = array(
- 'clientIp' => array(
- "enabled" => true,
- "name" => "X-Real-IP"
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainClientIp($domain, $clientIp);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain clientIp
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainClientIpThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $clientIp = array();
- $client->setDomainClientIp($domain, $clientIp);
- }
- /**
- * test get domain clientIp
- */
- public function testGetDomainClientIp() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainClientIp($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain clientIp
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainClientIpThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $client->getDomainClientIp($domain);
- }
- /**
- * test set domain followProtocol
- */
- public function testSetDomainFollowProtocol() {
- global $g_CDN_TEST_CONFIG;
- $followProtocol = array(
- 'followProtocol' => true
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainFollowProtocol($domain, $followProtocol);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain followProtocol
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainFollowProtocolThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $followProtocol = array();
- $client->setDomainFollowProtocol($domain, $followProtocol);
- }
- /**
- * test set domain rangeSwitch
- */
- public function testSetDomainRangeSwitch() {
- global $g_CDN_TEST_CONFIG;
- $rangeSwitch = array(
- 'rangeSwitch' => true
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainRangeSwitch($domain, $rangeSwitch);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain rangeSwitch
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainRangeSwitchThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $rangeSwitch = array();
- $client->setDomainRangeSwitch($domain, $rangeSwitch);
- }
- /**
- * test get domain rangeSwitch
- */
- public function testGetDomainRangeSwitch() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainRangeSwitch($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain rangeSwitch
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainRangeSwitchThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $client->getDomainRangeSwitch($domain);
- }
- /**
- * test set domain cacheShare off
- */
- public function testSetDomainCacheShareOff() {
- global $g_CDN_TEST_CONFIG;
- $cacheShare = array(
- 'cacheShare' => array(
- "enabled" => false,
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainCacheShare($domain, $cacheShare);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain cacheShare on
- */
- public function testSetDomainCacheShareOn() {
- global $g_CDN_TEST_CONFIG;
- $cacheShare = array(
- 'cacheShare' => array(
- "enabled" => true,
- "domain" => "duanhuiyan.top"
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainCacheShare($domain, $cacheShare);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain cacheShare
- */
- public function testGetDomainCacheShare() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainCacheShare($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain trafficLimit off
- */
- public function testSetDomainTrafficLimitOff() {
- global $g_CDN_TEST_CONFIG;
- $trafficLimit = array(
- 'trafficLimit' => array(
- "enable" => false,
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainTrafficLimit($domain, $trafficLimit);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain trafficLimit on
- */
- public function testSetDomainTrafficLimitOn() {
- global $g_CDN_TEST_CONFIG;
- $trafficLimit = array(
- 'trafficLimit' => array(
- "enable" => true,
- "limitRate" => 10485760,
- "limitStartHour" => 10,
- "limitEndHour" => 19,
- "limitRateAfter" => 0,
- "trafficLimitArg" => "rate",
- "trafficLimitUnit" => "m"
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainTrafficLimit($domain, $trafficLimit);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain trafficLimit
- */
- public function testGetDomainTrafficLimit() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainTrafficLimit($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain ua whiteList
- */
- public function testSetDomainUaWhiteList() {
- global $g_CDN_TEST_CONFIG;
- $flag = "white";
- $aclList = array(
- "MQQBrowser/5.3/Mozilla/5.0",
- "Mozilla/5.0 (Linux; Android 7.0"
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainUaAcl($domain, $flag, $aclList);
- $this->assertNotNull($resp);
- }
- /**
- * test delete domain ua whiteList
- */
- public function testDeleteDomainUaWhiteList() {
- global $g_CDN_TEST_CONFIG;
- $flag = "white";
- $aclList = array();
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainUaAcl($domain, $flag, $aclList);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain ua blackList
- */
- public function testSetDomainUaBlackList() {
- global $g_CDN_TEST_CONFIG;
- $flag = "black";
- $aclList = array(
- "MQQBrowser/5.3/Mozilla/5.0",
- "Mozilla/5.0 (Linux; Android 7.0"
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainUaAcl($domain, $flag, $aclList);
- $this->assertNotNull($resp);
- }
- /**
- * test delete domain ua blackList
- */
- public function testDeleteDomainUaBlackList() {
- global $g_CDN_TEST_CONFIG;
- $flag = "black";
- $aclList = array();
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainUaAcl($domain, $flag, $aclList);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain uaAcl
- */
- public function testGetDomainUaAcl() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainUaACL($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain originProtocol https, you need to turn on HTTPS first
- */
- public function testSetDomainOriginProtocolHttps() {
- global $g_CDN_TEST_CONFIG;
- $this->testSetDomainHttpsOn();
- $originProtocol = array(
- "originProtocol" => array(
- "value" => "https"
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainOriginProtocol($domain, $originProtocol);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain originProtocol http
- */
- public function testSetDomainOriginProtocolHttp() {
- global $g_CDN_TEST_CONFIG;
- $originProtocol = array(
- "originProtocol" => array(
- "value" => "http"
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainOriginProtocol($domain, $originProtocol);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain originProtocol follow
- */
- public function testSetDomainOriginProtocolFollow() {
- global $g_CDN_TEST_CONFIG;
- $originProtocol = array(
- "originProtocol" => array(
- "value" => "*"
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainOriginProtocol($domain, $originProtocol);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain retryOrigin
- */
- public function testSetDomainRetryOrigin() {
- global $g_CDN_TEST_CONFIG;
- $retryOrigin = array(
- "retryOrigin" => array(
- "codes" => array(
- 500,
- 502,
- 503
- )
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainRetryOrigin($domain, $retryOrigin);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain retryOrigin off
- */
- public function testSetDomainRetryOriginOff() {
- global $g_CDN_TEST_CONFIG;
- $retryOrigin = array(
- "retryOrigin" => array(
- "codes" => array()
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainRetryOrigin($domain, $retryOrigin);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain retryOrigin
- */
- public function testGetDomainRetryOrigin() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainRetryOrigin($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain ipv6Dispatch off
- */
- public function testSetDomainIpv6DispatchOff() {
- global $g_CDN_TEST_CONFIG;
- $ipv6Dispatch = array(
- "ipv6Dispatch" => array(
- "enable" => false
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainIpv6Dispatch($domain, $ipv6Dispatch);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain ipv6Dispatch
- */
- public function testGetDomainIpv6Dispatch() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainIpv6Dispatch($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain quic on
- */
- public function testSetDomainQuicOn() {
- global $g_CDN_TEST_CONFIG;
- $this->testSetDomainHttpsOn();
- $quic = array(
- "quic" => true
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainQuic($domain, $quic);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain quic off
- */
- public function testSetDomainQuicOff() {
- global $g_CDN_TEST_CONFIG;
- $quic = array(
- "quic" => false
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainQuic($domain, $quic);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain quic
- */
- public function testGetDomainQuic() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainQuic($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain offlineMode on
- */
- public function testSetDomainOfflineModeOn() {
- global $g_CDN_TEST_CONFIG;
- $offlineMode = array(
- "offlineMode" => true
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainOfflineMode($domain, $offlineMode);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain offlineMode off
- */
- public function testSetDomainOfflineModeOff() {
- global $g_CDN_TEST_CONFIG;
- $offlineMode = array(
- "offlineMode" => false
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainOfflineMode($domain, $offlineMode);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain offlineMode
- */
- public function testGetDomainOfflineMode() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainOfflineMode($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain ocsp on
- */
- public function testSetDomainOcspOn() {
- global $g_CDN_TEST_CONFIG;
-
- $this->testSetDomainHttpsOn();
- $ocsp = array(
- "ocsp" => true
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainOcsp($domain, $ocsp);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain ocsp off
- */
- public function testSetDomainOcspOff() {
- global $g_CDN_TEST_CONFIG;
- $ocsp = array(
- "ocsp" => false
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainOcsp($domain, $ocsp);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain ocsp
- */
- public function testGetDomainOcsp() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainOcsp($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get nodes list
- */
- public function testGetNodesList() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $resp = $client->getNodesList();
- $this->assertNotNull($resp);
- }
- /**
- * test set domain mobileAccess
- */
- public function testSetDomainMobileAccess() {
- global $g_CDN_TEST_CONFIG;
- $mobileAccess = array(
- 'mobileAccess' => array(
- "distinguishClient" => true
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainMobileAccess($domain, $mobileAccess);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain mobileAccess
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainMobileAccessThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $mobileAccess = array();
- $client->setDomainMobileAccess($domain, $mobileAccess);
- }
- /**
- * test get domain mobileAccess
- */
- public function testGetDomainMobileAccess() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainMobileAccess($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain mobileAccess
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainMobileAccessThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $client->getDomainMobileAccess($domain);
- }
- /**
- * test set domain httpHeader
- */
- public function testSetDomainHttpHeader() {
- global $g_CDN_TEST_CONFIG;
- $httpHeader = array(
- 'httpHeader' => array(
- array(
- "type" => "origin",
- "header" => "x-auth-cn",
- "value" => "xxxxxxxxx",
- "action" => "add"
- )
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainHttpHeader($domain, $httpHeader);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain httpHeader
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainHttpHeaderThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $httpHeader = array();
- $client->setDomainHttpHeader($domain, $httpHeader);
- }
- /**
- * test get domain httpHeader
- */
- public function testGetDomainHttpHeader() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainHttpHeader($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain httpHeader
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainHttpHeaderThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $client->getDomainHttpHeader($domain);
- }
- /**
- * test set domain seoSwitch
- */
- public function testSetDomainSeoSwitch() {
- global $g_CDN_TEST_CONFIG;
- $seoSwitch = array(
- 'seoSwitch' => array(
- "diretlyOrigin" => "ON",
- "pushRecord" => "OFF"
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainSeoSwitch($domain, $seoSwitch);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain seoSwitch
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainSeoSwitchThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $seoSwitch = array();
- $client->setDomainSeoSwitch($domain, $seoSwitch);
- }
- /**
- * test get domain seoSwitch
- */
- public function testGetDomainSeoSwitch() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainSeoSwitch($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain seoSwitch
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainSeoSwitchThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $client->getDomainSeoSwitch($domain);
- }
- /**
- * test set domain fileTrim
- */
- public function testSetDomainFileTrim() {
- global $g_CDN_TEST_CONFIG;
- $fileTrim = array(
- 'fileTrim' => true
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainFileTrim($domain, $fileTrim);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain fileTrim
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainFileTrimThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $fileTrim = array();
- $client->setDomainFileTrim($domain, $fileTrim);
- }
- /**
- * test get domain fileTrim
- */
- public function testGetDomainFileTrim() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainFileTrim($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain fileTrim
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainFileTrimThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $client->getDomainFileTrim($domain);
- }
- /**
- * test set domain mediaDrag
- */
- public function testSetDomainMediaDrag() {
- global $g_CDN_TEST_CONFIG;
- $mediaDrag = array(
- 'mediaDragConf' => array(
- 'mp4' => array(
- 'fileSuffix' => array('mp4'),
- 'startArgName' => 'startIndex',
- 'dragMode' => 'second',
- 'endArgName' => 'end'
- )
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainMediaDrag($domain, $mediaDrag);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain mediaDrag
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainMediaDragThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $mediaDrag = array();
- $client->setDomainMediaDrag($domain, $mediaDrag);
- }
- /**
- * test get domain mediaDrag
- */
- public function testGetDomainMediaDrag() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainMediaDrag($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain mediaDrag
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainMediaDragThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $client->getDomainMediaDrag($domain);
- }
- /**
- * test set domain compress
- */
- public function testSetDomainCompress() {
- global $g_CDN_TEST_CONFIG;
- $compress = array(
- 'compress' => array(
- "allow" => true,
- "type" => "br"
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainCompress($domain, $compress);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain compress
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainCompressThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $compress = array();
- $client->setDomainCompress($domain, $compress);
- }
- /**
- * test get domain compress
- */
- public function testGetDomainCompress() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainCompress($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain compress
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainCompressThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $client->getDomainCompress($domain);
- }
- /**
- * test set domain https off
- */
- public function testSetDomainHttpsOff() {
- global $g_CDN_TEST_CONFIG;
- $https = array(
- 'https' => array(
- "enabled" => false,
- "certId" => "----"//当enabled为true时该参数要为有效当证书id
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainHttps($domain, $https);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain https on
- */
- public function testSetDomainHttpsOn() {
- global $g_CDN_TEST_CONFIG;
- $https = array(
- 'https' => array(
- "enabled" => true,
- "certId" => "cert-qtah8qqwki6w"
- )
- );
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->setDomainHttps($domain, $https);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain https
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainHttpsThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $https = array();
- $client->setDomainHttps($domain, $https);
- }
- /**
- * test cache records
- */
- public function testGetRecords()
- {
- $resp = $this->client->getRecords();
- $this->assertNotNull($resp);
- }
- /**
- * test get domain cache ttl
- */
- public function testGetDomainCacheTTL()
- {
- $domain = "test-sdk.sys-qa.com";
- $resp = $this->client->getDomainCacheTTL($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain cache ttl
- */
- public function testSetDomainCacheTTL()
- {
- $domain = "test-sdk.sys-qa.com";
- $rules = array(
- array(
- "type" => "suffix",
- "value" => ".jpg",
- "ttl" => 36000,
- "weight" => 30,
- ),
- );
- $resp = $this->client->setDomainCacheTTL($domain, $rules);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain cache full url
- */
- public function testSetDomainCacheFullUrl()
- {
- $domain = "test-sdk.sys-qa.com";
- $flag = true;
- $resp = $this->client->setDomainCacheFullUrl($domain, $flag);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain ip acl
- */
- public function testSetDomainIpAcl()
- {
- $domain = "test-sdk.sys-qa.com";
- $aclList = array(
- "1.2.3.4",
- "5.6.7.8",
- );
- $flag = "white";
- $resp = $this->client->setDomainIpAcl($domain, $flag, $aclList);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain ip acl
- */
- public function testGetDomainIpACL() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainIpACL($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain refererAcl
- */
- public function testSetDomainRefererAcl()
- {
- $domain = "test-sdk.sys-qa.com";
- $aclList = array(
- "your.black.list1",
- "your.black.list2",
- );
- $flag = "black";
- $allowEmpty=true;
- $resp = $this->client->setDomainRefererAcl($domain, $flag, $allowEmpty, $aclList);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain refererAcl
- */
- public function testGetDomainRefererACL() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "test-sdk.sys-qa.com";
- $resp = $client->getDomainRefererAcl($domain);
- $this->assertNotNull($resp);
- }
- /**
- * test set domain limit rate
- */
- public function testSetDomainLimitRate()
- {
- $domain = "test-sdk.sys-qa.com";
- $rate = 1024;
- $resp = $this->client->setDomainLimitRate($domain, $rate);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain pv stat
- */
- public function testGetDomainPvStat()
- {
- $domain = 'test-sdk.sys-qa.com';
- $period = 300;
- $withRegion = 'true';
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $resp = $this->client->getDomainPvStat($domain, $startTime, $endTime,
- $period, $withRegion);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain uv stat
- */
- public function testGetDomainUvStat()
- {
- $domain = 'test-sdk.sys-qa.com';
- $period = 3600;
- $withRegion = 'true';
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $resp = $this->client->getDomainUvStat($domain, $startTime, $endTime, $period);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain avg speed stat
- */
- public function testGetDomainAvgSpeedStat()
- {
- $domain = 'test-sdk.sys-qa.com';
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $resp = $this->client->getDomainAvgSpeedStat($domain, $startTime, $endTime, $period);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain flow stat
- */
- public function testGetDomainFlowStat()
- {
- $domain = 'test-sdk.sys-qa.com';
- $period = 300;
- $withRegion = 'true';
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $resp = $this->client->getDomainFlowStat($domain, $startTime, $endTime,
- $period, $withRegion);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain src flow stat
- */
- public function testGetDomainSrcFlowStat()
- {
- $domain = 'test-sdk.sys-qa.com';
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $resp = $this->client->getDomainSrcFlowStat($domain, $startTime, $endTime, $period);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain hit rate stat
- */
- public function testGetDomainHitRateStat()
- {
- $domain = 'test-sdk.sys-qa.com';
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $resp = $this->client->getDomainHitRateStat($domain, $startTime, $endTime, $period);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain http code stat
- */
- public function testGetDomainHttpCodeStat()
- {
- $domain = 'test-sdk.sys-qa.com';
- $period = 300;
- $withRegion = 'true';
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $resp = $this->client->getDomainHttpCodeStat($domain, $startTime, $endTime,
- $period, $withRegion);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain top url stat
- */
- public function testGetDomainTopUrlStat()
- {
- $domain = 'test-sdk.sys-qa.com';
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $resp = $this->client->getDomainTopUrlStat($domain, $startTime, $endTime, $period);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain top referer stat
- */
- public function testGetDomainTopRefererStat()
- {
- $domain = 'test-sdk.sys-qa.com';
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $resp = $this->client->getDomainTopRefererStat($domain, $startTime, $endTime, $period);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats avg speed, new version
- */
- public function testGetDomainStatsAvgSpeed() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'metric' => 'avg_speed',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats avg speed by region, new version
- */
- public function testGetDomainStatsAvgSpeedRegion() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'prov' => 'beijing',
- 'isp' => 'ct',
- 'metric' => 'avg_speed_region',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats pv, new version
- */
- public function testGetDomainStatsPv() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'level' => 'edge',
- 'metric' => 'pv',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats pv by region, new version
- */
- public function testGetDomainStatsPvRegion() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'prov' => 'beijing',
- 'isp' => 'ct',
- 'metric' => 'pv_region',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats pv src, new version
- */
- public function testGetDomainStatsPvSrc() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'metric' => 'pv_src',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats uv, new version
- */
- public function testGetDomainStatsUv() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'metric' => 'uv',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats flow, new version
- */
- public function testGetDomainStatsFlow() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'level' => 'edge',
- 'metric' => 'flow',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats flow by protocol, new version
- */
- public function testGetDomainStatsFlowProtocol() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'protocol' => 'https',
- 'metric' => 'flow_protocol',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats flow by region, new version
- */
- public function testGetDomainStatsFLowRegion() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'prov' => 'beijing',
- 'isp' => 'ct',
- 'metric' => 'flow_region',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats flow src, new version
- */
- public function testGetDomainStatsFlowSrc() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'metric' => 'src_flow',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats hit rate, new version
- */
- public function testGetDomainStatsHit() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'metric' => 'real_hit',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats hit by pv, new version
- */
- public function testGetDomainStatsHitPv() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'metric' => 'pv_hit',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats http code, new version
- */
- public function testGetDomainStatsHttpCode() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'metric' => 'httpcode',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats http code by region, new version
- */
- public function testGetDomainStatsHttpCodeRegion() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $startTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'prov' => 'beijing',
- 'isp' => 'ct',
- 'metric' => 'httpcode_region',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats http code src, new version
- */
- public function testGetDomainStatsHttpCodeSrc() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'metric' => 'src_httpcode',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats top urls, new version
- */
- public function testGetDomainStatsTopUrls() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'extra' => 200,
- 'metric' => 'top_urls',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats top referers, new version
- */
- public function testGetDomainStatsTopReferers() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'extra' => 200,
- 'metric' => 'top_referers',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats top domains, new version
- */
- public function testGetDomainStatsTopDomains() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'groupBy' => '',
- 'extra' => 200,
- 'metric' => 'top_domains',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test get domain stats 4xx/5xx error reason, new version
- */
- public function testGetDomainStatsError() {
- $period = 300;
- $endTime = time();
- $startTime = $endTime - $period * 10;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $statParam = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'period' => $period,
- 'key_type' => 0,
- 'key' => array('test-sdk.sys-qa.com'),
- 'groupBy' => '',
- 'metric' => 'error',
- );
- $resp = $this->client->getDomainStats($statParam);
- $this->assertNotNull($resp);
- }
- /**
- * test prefetch
- */
- public function testPrefetch()
- {
- $this->markTestSkipped(
- 'skip'
- );
- $tasks = array(
- array(
- 'url' => 'http://test-sdk.sys-qa.com/path/to/file',
- ),
- );
- $resp = $this->client->prefetch($tasks);
- $this->assertNotNull($resp);
- $this->assertNotNull($resp->id);
- $resp = $this->client->listPrefetchStatus($resp->id);
- $this->assertNotNull($resp);
- }
- /**
- * test get prefetch status
- */
- public function testListPrefetchStatus()
- {
- $url = 'http://test-sdk.sys-qa.com/1.jpg';
- $endTime = time();
- $startTime = $endTime - 1000;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $resp = $this->client->listPrefetchStatus('', $url, $startTime, $endTime);
- $this->assertNotNull($resp);
- }
- /**
- * test purge
- */
- public function testPurge()
- {
- $this->markTestSkipped(
- 'skip'
- );
- $tasks = array(
- array(
- 'url' => 'http://test-sdk.sys-qa.com/path/to/file',
- ),
- array(
- 'url' => 'http://test-sdk.sys-qa.com/path/to/directory/',
- 'type' => 'directory',
- ),
- );
- $resp = $this->client->purge($tasks);
- $this->assertNotNull($resp);
- $this->assertNotNull($resp->id);
- $resp = $this->client->listPurgeStatus($resp->id);
- $this->assertNotNull($resp);
- }
- /**
- * test purge status
- */
- public function testListPurgeStatus()
- {
- $url = 'http://test-sdk.sys-qa.com/1.jpg';
- $endTime = time();
- $startTime = $endTime - 1000;
- $endTime = gmdate("Y-m-d\TH:i:s\Z", $endTime);
- $startTime = gmdate("Y-m-d\TH:i:s\Z", $startTime);
- $resp = $this->client->listPurgeStatus('', $url, $startTime, $endTime);
- $this->assertNotNull($resp);
- }
- /**
- * test list purge/prefetch quota
- */
- public function testListQuota()
- {
- $resp = $this->client->listQuota();
- $this->assertNotNull($resp);
- }
- /**
- * test get domain log
- */
- public function testGetDomainLog()
- {
- $domain = "test-sdk.sys-qa.com";
- $startTime = "2017-12-07T16:00:00Z";
- $endTime = "2017-12-07T18:00:00Z";
- $resp = $this->client->getDomainLog($domain, $startTime, $endTime);
- $this->assertNotNull($resp);
- }
- /**
- * test get domains log
- */
- public function testGetDomainsLog()
- {
- $domain = "test-sdk.sys-qa.com";
- $startTime = "2017-12-07T16:00:00Z";
- $endTime = "2017-12-07T18:00:00Z";
- $options = array(
- 'startTime' => $startTime,
- 'endTime' => $endTime,
- 'domains' => array(
- $domain
- )
- );
- $resp = $this->client->getDomainsLog($options);
- $this->assertNotNull($resp);
- }
- /**
- * test get domains log
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testGetDomainsLogThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $options = array();
- $client->getDomainsLog($options);
- }
- /**
- * test query ip
- */
- public function testIpQuery()
- {
- $ip = '1.2.3.4';
- $action = 'describeIp';
- $resp = $this->client->ipQuery($action, $ip);
- $this->assertNotNull($resp);
- }
- /**
- * test cache set das
- */
- public function testSetDsa()
- {
- $this->markTestSkipped(
- 'skip'
- );
- $action = array(
- "action" => "enable"
- );
- $resp = $this->client->setDsa($action);
- $this->assertEquals($resp, '');
- }
- /**
- * test set domain dsa config
- */
- public function testSetDomainDsa()
- {
- $dsa = array(
- 'dsa' => array(
- 'enabled' => true,
- 'rules' => array(
- array(
- 'type' => 'suffix',
- 'value' => '.mp4;.jpg;.php'
- )
- )
- )
- );
- $domain = "test-sdk.sys-qa.com";
- $resp = $this->client->setDomainDsa($domain, $dsa);
- $this->assertNotNull($resp);
- }
- /**
- * test cache set domain dsa config
- * @expectedException Exception
- * @throws \BaiduBce\Exception\BceClientException
- */
- public function testSetDomainDsaThrow() {
- global $g_CDN_TEST_CONFIG;
- $client = new CdnClient($g_CDN_TEST_CONFIG);
- $domain = "";
- $dsa = array();
- $client->setDomainDsa($domain, $dsa);
- }
- /**
- * test get dsa domain list
- */
- public function testGetDomainDsa()
- {
- $domain = "test-sdk.sys-qa.com";
- $resp = $this->client->getDomainDsa();
- $this->assertNotNull($resp);
- }
- }
|