Skip to content

Private tests cases #92

@Morriar

Description

@Morriar

For now, all the test cases are public since they are returned by the API:

For each submission we can see the provided inputs:

{
    "player": { ... },
    "mission": {
        "track": { ... },
        "title": "Addition simple",
        "desc": "...,
        "parents": { ... },
        "stars": { ... },
        "path": null,
        "solve_reward": 1,
        "reward": 20,
        "testsuite": {
            "__items": [{
                "__kind": "obj",
                "__id": 10,
                "__class": "TestCase",
                "provided_input": "5\n",
                "expected_output": "15\n"
            }, {
                "__kind": "obj",
                "__id": 11,
                "__class": "TestCase",
                "provided_input": "0\n",
                "expected_output": "10\n"
            }, {
                "__kind": "obj",
                "__id": 12,
                "__class": "TestCase",
                "provided_input": "-5\n",
                "expected_output": "5\n"
            }, {
                "__kind": "obj",
                "__id": 13,
                "__class": "TestCase",
                "provided_input": "-50\n",
                "expected_output": "-40\n"
            }]
        }
    },
}

So, the question is: should we return the real TestCase object or a modified one?

This is actually a very interesting question for the popcorn framework, maybe @ppepos will be interested.

In some cases, when serializing an object to the API, we do not want to return the full object as some data can be private or with a restricted access.

Examples:

  • lists of player submission that is not self
  • player score that is not self or a friend
  • private test inputs
  • ...

How can we provide a kiss serialization mechanism with right handling?

From what I remember from the discussion with @ppepos on a related problem, here my proposal for a quick and dirty workaround:

  • by default, all data are marked as public
  • we use an annotation to mark restricted data and give them an arbitrary right level ():
class User
    # Public string
    var name: String

    # Restricted to self (and admins):
    var email: String is restricted(self)

    # Restricted to self and friends:
    var score: Int is restricted(friends)
end

And then, the JSON serialization process will take out restricted data depending on a user (lot of code to handle annotations required but somehow a clean an unified process?).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions