Skip to content

Commit

Permalink
added failing test + workaround (proxy/JWT implementation will outdat…
Browse files Browse the repository at this point in the history
…e the token field completely)
  • Loading branch information
alexbarcelo committed Sep 4, 2024
1 parent 378232e commit 653eec7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/dataclay/backend/servicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ def _validate_context(servicer, context) -> Optional[str]:
# set the current_context
if "dataset-name" in metadata and "username" in metadata:
session_var.set(
{"dataset_name": metadata["dataset-name"], "username": metadata["username"]}
{
"dataset_name": metadata["dataset-name"],
"username": metadata["username"],
"token": b"",
}
)
return None

Expand Down
34 changes: 34 additions & 0 deletions tests/functional/test_activemethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,40 @@ def test_activemethod_inner_make_persistent(client):
assert puppy.age == 0


def test_activemethod_nested_getattribute(client):
"""
An activemethod that calls multiple getattribute inside
"""
family = Family()
family.make_persistent()

# Technically, there is a change that all the following objects
# are made persistent in a single backend and thus this test
# may be inconclusive. The chance is (1/n_backends)^(n_objects - 1).

# Increment either n to feel safer, or change the make_persistent
# to be deterministically correct.

person = Person("Marc", 24)
person.make_persistent()
family.add(person)
person = Person("Anna", 24)
person.make_persistent()
family.add(person)
dog = Dog("Duna", 6)
dog.make_persistent()
family.add(dog)
dog = Dog("Luna", 6)
dog.make_persistent()
family.add(dog)

family_str = str(family) # This calls the __str__ activemethod
assert "Marc" in family_str
assert "Anna" in family_str
assert "Duna" in family_str
assert "Luna" in family_str


# Remote methods


Expand Down

0 comments on commit 653eec7

Please sign in to comment.