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