aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hashserv
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2023-11-03 08:26:40 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-11-09 17:21:15 +0000
commita9fd4a45bb6e5ac9832835897f594f3bbf67e1aa (patch)
tree0824b474febd66f0512b8ecaf67b0d0df221ad85 /lib/hashserv
parent2d4439948a5328a9768bca9eaec221eb82af3cb2 (diff)
downloadbitbake-a9fd4a45bb6e5ac9832835897f594f3bbf67e1aa.tar.gz
hashserv: server: Add owner if user is logged in
If a user is authenticated with the server, report them as the owner of a report Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/hashserv')
-rw-r--r--lib/hashserv/server.py3
-rw-r--r--lib/hashserv/tests.py9
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/hashserv/server.py b/lib/hashserv/server.py
index 439962f78..a86507830 100644
--- a/lib/hashserv/server.py
+++ b/lib/hashserv/server.py
@@ -475,6 +475,9 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
if k in data:
outhash_data[k] = data[k]
+ if self.user:
+ outhash_data["owner"] = self.user.username
+
# Insert the new entry, unless it already exists
if await self.db.insert_outhash(outhash_data):
# If this row is new, check if it is equivalent to another
diff --git a/lib/hashserv/tests.py b/lib/hashserv/tests.py
index f0be86791..a9e6fdf9f 100644
--- a/lib/hashserv/tests.py
+++ b/lib/hashserv/tests.py
@@ -828,6 +828,15 @@ class HashEquivalenceCommonTests(object):
for col in columns:
self.client.remove({col: ""})
+ def test_auth_is_owner(self):
+ admin_client = self.start_auth_server()
+
+ user = self.create_user("test-user", ["@read", "@report"])
+ with self.auth_client(user) as client:
+ taskhash, outhash, unihash = self.create_test_hash(client)
+ data = client.get_taskhash(self.METHOD, taskhash, True)
+ self.assertEqual(data["owner"], user["username"])
+
class TestHashEquivalenceClient(HashEquivalenceTestSetup, unittest.TestCase):
def get_server_addr(self, server_idx):