Skip to content

Commit 944ef80

Browse files
author
guillermo-fisher
committed
Added ManagementConsole tests.
1 parent de4eeb4 commit 944ef80

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?php
2+
/**
3+
* This file is part of the php-github-api package.
4+
*
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*/
8+
9+
namespace Github\Tests\Api\Enterprise;
10+
11+
use Github\Tests\Api\TestCase;
12+
13+
class ManagementConsoleTest extends TestCase
14+
{
15+
/**
16+
* @test
17+
*/
18+
public function shouldShowConfigData()
19+
{
20+
$expectedJson = '{ "status": "running", "progress": [ { "status": "DONE", "key": "Appliance core components" },
21+
{ "status": "DONE", "key": "GitHub utilities" }, { "status": "DONE", "key": "GitHub applications" },
22+
{ "status": "CONFIGURING", "key": "GitHub services" }, { "status": "PENDING", "key":
23+
"Reloading appliance services" } ] }';
24+
$expectedArray = json_encode($expectedJson);
25+
26+
$api = $this->getApiMock();
27+
$api->expects($this->once())
28+
->method('get')
29+
->with('/setup/api/configcheck')
30+
->will($this->returnValue($expectedArray));
31+
32+
$this->assertEquals($expectedArray, $api->configcheck($this->getLicenseHash()));
33+
}
34+
35+
/**
36+
* @test
37+
*/
38+
public function shouldShowSettingsData()
39+
{
40+
$expectedJson = '{ "enterprise": { "private_mode": false, "github_hostname": "ghe.local", "auth_mode":
41+
"default", "storage_mode": "rootfs", "admin_password": null, "configuration_id": 1401777404,
42+
"configuration_run_count": 4, "package_version": "11.10.332", "avatar": { "enabled": false, "uri": "" },
43+
"customer": { "name": "GitHub", "email": "[email protected]", "uuid":
44+
"af6cac80-e4e1-012e-d822-1231380e52e9",
45+
"secret_key_data": "-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\n\nlQcYBE5TCgsBEACk4yHpUcapplebaumBMXYMiLF+nCQ0lxpx...\n-----END PGP PRIVATE KEY BLOCK-----\n",
46+
"public_key_data": "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\n\nmI0ETqzZYgEEALSe6snowdenXyqvLfSQ34HWD6C7....\n-----END PGP PUBLIC KEY BLOCK-----\n" },
47+
"license": { "seats": 0, "evaluation": false, "expire_at": "2015-04-27T00:00:00-07:00", "perpetual": false,
48+
"unlimited_seating": true, "support_key": "ssh-rsa AAAAB3N....", "ssh_allowed": true }, "github_ssl":
49+
{ "enabled": false, "cert": null, "key": null }, "ldap": { "host": "", "port": "", "base": [ ], "uid": "",
50+
"bind_dn": "", "password": "", "method": "Plain", "user_groups": [ ], "admin_group": "" }, "cas": { "url": "" },
51+
"github_oauth": { "client_id": "12313412", "client_secret": "kj123131132", "organization_name":
52+
"Homestar Runners", "organization_team": "homestarrunners/owners" }, "smtp": { "enabled": true, "address":
53+
"smtp.example.com", "authentication": "plain", "port": "1234", "domain": "blah", "username": "foo", "user_name":
54+
"mr_foo", "enable_starttls_auto": true, "password": "bar", "support_address": "[email protected]",
55+
"noreply_address": "[email protected]" }, "dns": { "primary_nameserver": "8.8.8.8", "secondary_nameserver":
56+
"8.8.4.4" }, "ntp": { "primary_server": "0.ubuntu.pool.ntp.org", "secondary_server": "1.ubuntu.pool.ntp.org" },
57+
"timezone": { "identifier": "UTC" }, "device": { "path": "/dev/xyz" }, "snmp": { "enabled": false,
58+
"community": "" }, "rsyslog": { "enabled": false, "server": "", "protocol_name": "TCP" }, "assets": { "storage":
59+
"file", "bucket": null, "host_name": null, "key_id": null, "access_key": null }, "pages": { "enabled": true },
60+
"collectd": { "enabled": false, "server": "", "port": "", "encryption": "", "username": "foo", "password":
61+
"bar" } }, "run_list": [ "role[configure]" ] }';
62+
$expectedArray = json_encode($expectedJson);
63+
64+
$api = $this->getApiMock();
65+
$api->expects($this->once())
66+
->method('get')
67+
->with('/setup/api/settings')
68+
->will($this->returnValue($expectedArray));
69+
70+
$this->assertEquals($expectedArray, $api->settings($this->getLicenseHash()));
71+
}
72+
73+
/**
74+
* @test
75+
*/
76+
public function shouldShowMaintenanceStatus()
77+
{
78+
$expectedJson = '{ "status": "scheduled", "scheduled_time": "Tuesday, January 22 at 15 => 34 -0800",
79+
"connection_services": [ { "name": "git operations", "number": 0 }, { "name": "mysql queries", "number": 233 },
80+
{ "name": "resque jobs", "number": 54 } ] }';
81+
$expectedArray = json_encode($expectedJson);
82+
83+
$api = $this->getApiMock();
84+
$api->expects($this->once())
85+
->method('get')
86+
->with('/setup/api/maintenance')
87+
->will($this->returnValue($expectedArray));
88+
89+
$this->assertEquals($expectedArray, $api->maintenance($this->getLicenseHash()));
90+
}
91+
92+
/**
93+
* @test
94+
*/
95+
public function shouldShowAuthorizedKeys()
96+
{
97+
$expectedJson = '[ { "key": "ssh-rsa AAAAB3NzaC1yc2EAAAAB...", "pretty-print":
98+
"ssh-rsa 01:14:0f:f2:0f:e2:fe:e8:f4:72:62:af:75:f7:1a:88:3e:04:92:64" },
99+
{ "key": "ssh-rsa AAAAB3NzaC1yc2EAAAAB...", "pretty-print":
100+
"ssh-rsa 01:14:0f:f2:0f:e2:fe:e8:f4:72:62:af:75:f7:1a:88:3e:04:92:64" } ]';
101+
$expectedArray = json_encode($expectedJson);
102+
103+
$api = $this->getApiMock();
104+
$api->expects($this->once())
105+
->method('get')
106+
->with('/setup/api/settings/authorized-keys')
107+
->will($this->returnValue($expectedArray));
108+
109+
$this->assertEquals($expectedArray, $api->keys($this->getLicenseHash()));
110+
}
111+
112+
protected function getLicenseHash()
113+
{
114+
return '1234567890abcdefghijklmnopqrstuv';
115+
}
116+
117+
protected function getApiClass()
118+
{
119+
return 'Github\Api\Enterprise\ManagementConsole';
120+
}
121+
}

0 commit comments

Comments
 (0)