Skip to content

Commit

Permalink
Remove vestiges of authorisation layer removed in #3845
Browse files Browse the repository at this point in the history
  • Loading branch information
MetRonnie committed Feb 20, 2025
1 parent f751949 commit b81932c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 83 deletions.
8 changes: 3 additions & 5 deletions cylc/flow/network/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"""Package for network interfaces to Cylc scheduler objects."""

import asyncio
import getpass
import json
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -104,10 +103,9 @@ def stringify(data: object) -> str:

def parse(message: str) -> 'ResponseDict':
"""Convert a JSON message string to dict with an added 'user' field."""
msg = json.loads(message)
if 'user' not in msg:
msg['user'] = getpass.getuser() # assume this is the user
return msg
# Abstract out the transport format in order to allow it to be changed
# in future.
return json.loads(message)


def get_location(workflow: str) -> Tuple[str, int, int]:
Expand Down
44 changes: 0 additions & 44 deletions cylc/flow/network/authorisation.py

This file was deleted.

6 changes: 0 additions & 6 deletions cylc/flow/network/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
from cylc.flow.cfgspec.glbl_cfg import glbl_cfg
from cylc.flow.data_messages_pb2 import PbEntireWorkflow
from cylc.flow.data_store_mgr import DELTAS_MAP
from cylc.flow.network.authorisation import authorise
from cylc.flow.network.graphql import (
CylcGraphQLBackend,
IgnoreFieldMiddleware,
Expand Down Expand Up @@ -299,7 +298,6 @@ def receiver(self, message) -> 'ResponseDict':
try:
method = getattr(self, message['command'])
args = message['args']
args.update({'user': message['user']})
if 'meta' in message:
args['meta'] = message['meta']
except KeyError as exc:
Expand Down Expand Up @@ -347,7 +345,6 @@ def register_endpoints(self):
for name, obj in self.__class__.__dict__.items()
if hasattr(obj, 'exposed')}

@authorise()
@expose
def api(
self,
Expand Down Expand Up @@ -384,7 +381,6 @@ def api(
return '%s\n%s' % (head, tail)
return 'No method by name "%s"' % endpoint

@authorise()
@expose
def graphql(
self,
Expand Down Expand Up @@ -423,7 +419,6 @@ def graphql(
return executed.data

# UIServer Data Commands
@authorise()
@expose
def pb_entire_workflow(self, **_kwargs) -> bytes:
"""Send the entire data-store in a single Protobuf message.
Expand All @@ -434,7 +429,6 @@ def pb_entire_workflow(self, **_kwargs) -> bytes:
pb_msg = self.schd.data_store_mgr.get_entire_workflow()
return pb_msg.SerializeToString()

@authorise()
@expose
def pb_data_elements(self, element_type: str, **_kwargs) -> bytes:
"""Send the specified data elements in delta form.
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/network/test_replier.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import asyncio
import getpass

from async_timeout import timeout
import pytest
Expand All @@ -40,7 +39,6 @@ async def test_listener(one: Scheduler, start):
assert 'data' not in res
# Check other fields are present:
assert res['cylc_version'] == CYLC_VERSION
assert res['user'] == getpass.getuser()

one.server.replier.queue.put('STOP')
async with timeout(2):
Expand Down
31 changes: 5 additions & 26 deletions tests/integration/network/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

import logging
from typing import Callable
from async_timeout import timeout
from getpass import getuser

from async_timeout import timeout
import pytest
from cylc.flow import __version__ as CYLC_VERSION

from cylc.flow import __version__ as CYLC_VERSION
from cylc.flow.network.server import PB_METHOD_MAP
from cylc.flow.scheduler import Scheduler

Expand All @@ -34,16 +33,6 @@ async def myflow(mod_flow, mod_scheduler, mod_run, mod_one_conf):
yield schd


def run_server_method(schd, method, *args, **kwargs):
kwargs['user'] = getuser()
return getattr(schd.server, method)(*args, **kwargs)


def call_server_method(method, *args, **kwargs):
kwargs['user'] = getuser()
return method(*args, **kwargs)


def test_graphql(myflow):
"""Test GraphQL endpoint method."""
request_string = f'''
Expand All @@ -53,7 +42,7 @@ def test_graphql(myflow):
}}
}}
'''
data = call_server_method(myflow.server.graphql, request_string)
data = myflow.server.graphql(request_string)
assert myflow.id == data['workflows'][0]['id']


Expand All @@ -62,10 +51,7 @@ def test_pb_data_elements(myflow):
element_type = 'workflow'
data = PB_METHOD_MAP['pb_data_elements'][element_type]()
data.ParseFromString(
call_server_method(
myflow.server.pb_data_elements,
element_type
)
myflow.server.pb_data_elements(element_type)
)
assert data.added.id == myflow.id

Expand All @@ -74,9 +60,7 @@ def test_pb_entire_workflow(myflow):
"""Test Protobuf entire workflow endpoint method."""
data = PB_METHOD_MAP['pb_entire_workflow']()
data.ParseFromString(
call_server_method(
myflow.server.pb_entire_workflow
)
myflow.server.pb_entire_workflow()
)
assert data.workflow.id == myflow.id

Expand Down Expand Up @@ -118,11 +102,6 @@ def _api(*args, **kwargs):
@pytest.mark.parametrize(
'msg, expected',
[
pytest.param(
{'command': 'api', 'args': {}},
f"Request missing field 'user' required for Cylc {CYLC_VERSION}",
id='missing-user',
),
pytest.param(
{'user': 'bono', 'args': {}},
f"Request missing field 'command' required for Cylc {CYLC_VERSION}",
Expand Down

0 comments on commit b81932c

Please sign in to comment.