Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions webapp/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,24 +434,24 @@ public function getRoleList(): array
#[Serializer\VirtualProperty]
#[Serializer\SerializedName('type')]
#[Serializer\Type('string')]
public function getType(): ?string
public function getType(): string
{
// Types allowed by the CCS Specs Contest API in order of most permissions to least.
// Types suggested by the CCS Specs Contest API in order of most permissions to least.
// Either key=>value where key is the DOMjudge role and value is the API account type or
// only value, where both the DOMjudge role and API type are the same.
$allowedTypes = ['admin', 'api_writer' => 'admin', 'api_reader' => 'admin',
'jury' => 'judge', 'api_source_reader' => 'judge',
'team'];
foreach ($allowedTypes as $role => $allowedType) {
$mappedTypes = ['admin', 'api_writer' => 'admin', 'api_reader' => 'admin',
'jury' => 'judge', 'api_source_reader' => 'judge',
'team'];
foreach ($mappedTypes as $role => $mappedType) {
if (is_numeric($role)) {
$role = $allowedType;
$role = $mappedType;
}
if (in_array($role, $this->getRoleList())) {
return $allowedType;
return $mappedType;
}
}

return null;
return 'other';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 'other';
return 'domjudge_internal';

So other systems reading it know who to contact if they want to do anything with the account.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not strongly against this, but why is this better than just other? If you're querying the DOMjudge API, you know the source already. Do we want to distinguish our nonstandard accounts from possibly another system's nonstandard accounts?x

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CDS might know the source, but things behind the CDS don't, if you make contest exports it's more convenient etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a slight preference for other but am also fine with domjudge_internal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also prefer other. I prefer a generic term that can potentially be added to the spec than something DOMjudge specific, as I don't see a case where you'd not know or easily figure out this came from DOMjudge.

}

/**
Expand Down
6 changes: 3 additions & 3 deletions webapp/tests/Unit/Controller/API/AccountBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ abstract class AccountBaseTestCase extends BaseTestCase
[['type' => 'api_writer'], ['type' => 'admin', 'roles' => ['api_writer']]],
[['type' => 'api_reader'], ['type' => 'admin', 'roles' => ['api_reader']]],
[['type' => 'api_source_reader'], ['type' => 'judge', 'roles' => ['api_source_reader']]],
[['type' => 'balloon'], ['roles' => ['balloon'], 'type' => null]],
[['type' => 'clarification_rw'], ['roles' => ['clarification_rw'], 'type' => null]],
[['type' => 'balloon'], ['roles' => ['balloon'], 'type' => 'other']],
[['type' => 'clarification_rw'], ['roles' => ['clarification_rw'], 'type' => 'other']],
[['type' => 'cds'], ['roles' => ['api_source_reader', 'api_reader', 'api_writer'], 'type' => 'admin']],
[['username' => 'cds', 'type' => 'admin'], ['roles' => ['api_source_reader', 'api_reader', 'api_writer'], 'type' => 'admin']],
[['username' => 'cds', 'type' => 'jury'], ['roles' => ['api_source_reader', 'api_reader', 'api_writer'], 'type' => 'admin']],
];

protected static array $accountAddCombinationsWithoutFile = [
[['username' => 'cds', 'roles' => ['admin']], ['roles' => ['api_source_reader', 'api_reader', 'api_writer'], 'type' => 'admin']],
[['username' => 'another_judgehost', 'roles' => ['judgehost']], ['type' => null]],
[['username' => 'another_judgehost', 'roles' => ['judgehost']], ['type' => 'other']],
];

protected static array $optionalAddKeys = ['id', 'name', 'password'];
Expand Down
2 changes: 1 addition & 1 deletion webapp/tests/Unit/Controller/API/AccountControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AccountControllerTest extends AccountBaseTestCase
"id" => "judgehost",
"username" => "judgehost",
"team_id" => null,
"type" => null,
"type" => "other",
"ip" => null,
],
'demo' => [
Expand Down
Loading