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
12 changes: 12 additions & 0 deletions gvm/protocols/gmp/_gmpnext.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,18 @@ def get_agent_support_bundle(
)
)

def get_agent_inventory_token(self) -> T:
"""Request a short-lived agent inventory token.

The token is used to authenticate requests to the agent-control API
using Authorization: Bearer <token>.

The authenticated user must have the get_agents permission.
"""
return self._send_request_and_transform_response(
Agents.get_agent_inventory_token()
)

def create_active_directory_credential(
self,
name: str,
Expand Down
14 changes: 14 additions & 0 deletions gvm/protocols/gmp/requests/next/_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,17 @@ def get_agent_support_bundle(
cmd.set_attribute("anonymized", to_bool(anonymized))

return cmd

@classmethod
def get_agent_inventory_token(cls) -> Request:
"""Request a short-lived agent inventory token.

The token is used to authenticate requests to the agent-control API
using the Authorization: Bearer <token> header.

The authenticated user must have the get_agents permission.

Returns:
Request: GMP request for an agent inventory token.
"""
return XmlCommand("get_agent_inventory_token")
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2026 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later


class GmpGetAgentInventoryTokenTestMixin:
def test_get_agent_inventory_token(self):
self.gmp.get_agent_inventory_token()

self.connection.send.has_been_called_with(
b"<get_agent_inventory_token/>"
)
9 changes: 9 additions & 0 deletions tests/protocols/gmpnext/entities/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from .agents.test_delete_agents import (
GmpDeleteAgentsTestMixin,
)
from .agents.test_get_agent_inventory_token import (
GmpGetAgentInventoryTokenTestMixin,
)
from .agents.test_get_agent_support_bundle import (
GmpGetAgentSupportBundleTestMixin,
)
Expand Down Expand Up @@ -48,3 +51,9 @@ class GmpGetAgentSupportBundleTestCase(
GmpGetAgentSupportBundleTestMixin, GMPTestCase
):
pass


class GmpGetAgentInventoryTokenTestCase(
GmpGetAgentInventoryTokenTestMixin, GMPTestCase
):
pass
Loading