Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
fix(enrollment): fix computer type affectation in enrollment process
Browse files Browse the repository at this point in the history
  • Loading branch information
btry authored and DIOHz0r committed Nov 23, 2017
1 parent 98555da commit 3306264
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
23 changes: 12 additions & 11 deletions inc/agent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1000,12 +1000,12 @@ protected function enrollByInvitationToken($input) {
$input = [];

$config = Config::getConfigurationValues("flyvemdm", [
'mqtt_tls_for_clients',
'mqtt_use_client_cert',
'debug_noexpire',
'computertypes_id',
'agentusercategories_id',
'agent_profiles_id',
'mqtt_tls_for_clients',
'mqtt_use_client_cert',
'debug_noexpire',
'computertypes_id',
'agentusercategories_id',
'agent_profiles_id',
]);

// Find the invitation
Expand Down Expand Up @@ -1188,11 +1188,12 @@ protected function enrollByInvitationToken($input) {
// Create the device
$computer = new Computer();
$computerId = $computer->add([
'name' => $email,
'users_id' => $userId,
'entities_id' => $entityId,
'serial' => $serial,
'uuid' => $uuid,
'name' => $email,
'users_id' => $userId,
'entities_id' => $entityId,
'serial' => $serial,
'uuid' => $uuid,
'computertypes_id' => $computerTypeId,
]);
if ($computerId === false) {
$event = __("Cannot create the device", 'flyvemdm');
Expand Down
2 changes: 1 addition & 1 deletion inc/package.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
* @param integer $ID ID of the item to show
* @param array $options
*/
public function showForm($ID, $options=[]) {
public function showForm($ID, array $options = []) {
$this->initForm($ID, $options);
$this->showFormHeader($options);

Expand Down
7 changes: 7 additions & 0 deletions tests/suite-integration/PluginFlyvemdmAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public function testDeviceCountLimit() {
* @tags testEnrollAgent
*/
public function testEnrollAgent() {
// Set a computer type
$computerTypeId = 3;
\Config::setConfigurationValues('flyvemdm', ['computertypes_id' => $computerTypeId]);

list($user, $serial, $guestEmail, $invitation) = $this->createUserInvitation(\User::getForeignKeyField());

$invitationToken = $invitation->getField('invitation_token');
Expand Down Expand Up @@ -183,6 +187,9 @@ public function testEnrollAgent() {
$computer = new \Computer();
$this->boolean($computer->getFromDB($agent->getField(\Computer::getForeignKeyField())))->isTrue();

// Test the computer has the expected type
$this->string($computer->getField('computertypes_id'))->isEqualTo($computerTypeId);

// Test the serial is saved
$this->string($computer->getField('serial'))->isEqualTo($serial);

Expand Down

0 comments on commit 3306264

Please sign in to comment.