Skip to content

Réinitialiser l'état du serveur de test

Charles-Edouard Coste edited this page Sep 13, 2015 · 1 revision

La grosse difficulté pour mettre le projet sous intégration continue est l’absence de service web sur le serveur de qualification pour remettre une station à son état initiale. Le script suivant permet de réinitialiser une station.

$host = 'xxx';
$credentials = array(
    'username' => 'xxx',
    'password' => 'xxx'
);
$station = '0000';

$ch = curl_init();

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie-name');

// Requête 1
curl_setopt($ch, CURLOPT_URL, "https://{$host}/efs/signon/usernamePasswordLogin.do");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $credentials);
curl_exec($ch);

// Requête 2
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, array());
curl_setopt($ch, CURLOPT_URL, "https://{$host}/efs/private/perso/myStations.do?parameter=view");
curl_exec($ch);

// Requête 3
curl_setopt($ch, CURLOPT_URL, "https://{$host}/efs/private/perso/myStations.do?parameter=reinitialize&idStation={$station}");
curl_exec($ch);