mirror of
https://github.com/ngrok/ngrok-api-python.git
synced 2026-06-16 16:54:33 +00:00
Remove deprecated edge and backend API tests
- Remove test_backends() function that tests deprecated backend APIs - Remove test_tcp_edges() function that tests deprecated TCP edge APIs - Remove test_tls_edges() function that tests deprecated TLS edge APIs - Remove test_https_edges() function that tests deprecated HTTPS edge APIs - Update generated client code to reflect API deprecations These test functions would no longer pass due to the deprecation of edge and backend related APIs. The client library no longer exposes these APIs. Amp-Thread-ID: https://ampcode.com/threads/T-40db5ce4-b00c-48f1-b53a-467c3454aadd Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
committed by
Eric Anderle
co-authored by
Amp
parent
c7ed09b32d
commit
4918d2d51f
@@ -129,41 +129,9 @@ API Reference
|
||||
application_sessions
|
||||
application_users
|
||||
tunnel_sessions
|
||||
failover_backends
|
||||
http_response_backends
|
||||
static_backends
|
||||
tunnel_group_backends
|
||||
weighted_backends
|
||||
bot_users
|
||||
certificate_authorities
|
||||
credentials
|
||||
edges_https_routes
|
||||
edges_https
|
||||
https_edge_mutual_tls_module
|
||||
https_edge_tls_termination_module
|
||||
edge_route_backend_module
|
||||
edge_route_ip_restriction_module
|
||||
edge_route_request_headers_module
|
||||
edge_route_response_headers_module
|
||||
edge_route_compression_module
|
||||
edge_route_circuit_breaker_module
|
||||
edge_route_webhook_verification_module
|
||||
edge_route_o_auth_module
|
||||
edge_route_saml_module
|
||||
edge_route_oidc_module
|
||||
edge_route_websocket_tcp_converter_module
|
||||
edge_route_user_agent_filter_module
|
||||
edge_route_traffic_policy_module
|
||||
edges_tcp
|
||||
tcp_edge_backend_module
|
||||
tcp_edge_ip_restriction_module
|
||||
tcp_edge_traffic_policy_module
|
||||
edges_tls
|
||||
tls_edge_backend_module
|
||||
tls_edge_ip_restriction_module
|
||||
tls_edge_mutual_tls_module
|
||||
tls_edge_tls_termination_module
|
||||
tls_edge_traffic_policy_module
|
||||
endpoints
|
||||
event_destinations
|
||||
event_subscriptions
|
||||
|
||||
-102
@@ -174,105 +174,3 @@ class Client(object):
|
||||
def vaults(self) -> VaultsClient:
|
||||
"""Vaults is an api service for securely storing and managing sensitive data such as secrets, credentials, and tokens."""
|
||||
return VaultsClient(self)
|
||||
|
||||
@property
|
||||
def backends(self):
|
||||
ns = collections.namedtuple(
|
||||
"Namespace",
|
||||
[
|
||||
"failover",
|
||||
"http_response",
|
||||
"static_address",
|
||||
"tunnel_group",
|
||||
"weighted",
|
||||
],
|
||||
)
|
||||
return ns(
|
||||
failover=FailoverBackendsClient(self),
|
||||
http_response=HTTPResponseBackendsClient(self),
|
||||
static_address=StaticBackendsClient(self),
|
||||
tunnel_group=TunnelGroupBackendsClient(self),
|
||||
weighted=WeightedBackendsClient(self),
|
||||
)
|
||||
|
||||
@property
|
||||
def edges(self):
|
||||
ns = collections.namedtuple(
|
||||
"Namespace",
|
||||
[
|
||||
"https_routes",
|
||||
"https",
|
||||
"tcp",
|
||||
"tls",
|
||||
],
|
||||
)
|
||||
return ns(
|
||||
https_routes=EdgesHTTPSRoutesClient(self),
|
||||
https=EdgesHTTPSClient(self),
|
||||
tcp=EdgesTCPClient(self),
|
||||
tls=EdgesTLSClient(self),
|
||||
)
|
||||
|
||||
@property
|
||||
def edge_modules(self):
|
||||
ns = collections.namedtuple(
|
||||
"Namespace",
|
||||
[
|
||||
"https_edge_mutual_tls",
|
||||
"https_edge_tls_termination",
|
||||
"https_edge_route_backend",
|
||||
"https_edge_route_ip_restriction",
|
||||
"https_edge_route_request_headers",
|
||||
"https_edge_route_response_headers",
|
||||
"https_edge_route_compression",
|
||||
"https_edge_route_circuit_breaker",
|
||||
"https_edge_route_webhook_verification",
|
||||
"https_edge_route_oauth",
|
||||
"https_edge_route_saml",
|
||||
"https_edge_route_oidc",
|
||||
"https_edge_route_websocket_tcp_converter",
|
||||
"https_edge_route_user_agent_filter",
|
||||
"https_edge_route_traffic_policy",
|
||||
"tcp_edge_backend",
|
||||
"tcp_edge_ip_restriction",
|
||||
"tcp_edge_traffic_policy",
|
||||
"tls_edge_backend",
|
||||
"tls_edge_ip_restriction",
|
||||
"tls_edge_mutual_tls",
|
||||
"tls_edge_tls_termination",
|
||||
"tls_edge_traffic_policy",
|
||||
],
|
||||
)
|
||||
return ns(
|
||||
https_edge_mutual_tls=HTTPSEdgeMutualTLSModuleClient(self),
|
||||
https_edge_tls_termination=HTTPSEdgeTLSTerminationModuleClient(self),
|
||||
https_edge_route_backend=EdgeRouteBackendModuleClient(self),
|
||||
https_edge_route_ip_restriction=EdgeRouteIPRestrictionModuleClient(self),
|
||||
https_edge_route_request_headers=EdgeRouteRequestHeadersModuleClient(self),
|
||||
https_edge_route_response_headers=EdgeRouteResponseHeadersModuleClient(
|
||||
self
|
||||
),
|
||||
https_edge_route_compression=EdgeRouteCompressionModuleClient(self),
|
||||
https_edge_route_circuit_breaker=EdgeRouteCircuitBreakerModuleClient(self),
|
||||
https_edge_route_webhook_verification=EdgeRouteWebhookVerificationModuleClient(
|
||||
self
|
||||
),
|
||||
https_edge_route_oauth=EdgeRouteOAuthModuleClient(self),
|
||||
https_edge_route_saml=EdgeRouteSAMLModuleClient(self),
|
||||
https_edge_route_oidc=EdgeRouteOIDCModuleClient(self),
|
||||
https_edge_route_websocket_tcp_converter=EdgeRouteWebsocketTCPConverterModuleClient(
|
||||
self
|
||||
),
|
||||
https_edge_route_user_agent_filter=EdgeRouteUserAgentFilterModuleClient(
|
||||
self
|
||||
),
|
||||
https_edge_route_traffic_policy=EdgeRouteTrafficPolicyModuleClient(self),
|
||||
tcp_edge_backend=TCPEdgeBackendModuleClient(self),
|
||||
tcp_edge_ip_restriction=TCPEdgeIPRestrictionModuleClient(self),
|
||||
tcp_edge_traffic_policy=TCPEdgeTrafficPolicyModuleClient(self),
|
||||
tls_edge_backend=TLSEdgeBackendModuleClient(self),
|
||||
tls_edge_ip_restriction=TLSEdgeIPRestrictionModuleClient(self),
|
||||
tls_edge_mutual_tls=TLSEdgeMutualTLSModuleClient(self),
|
||||
tls_edge_tls_termination=TLSEdgeTLSTerminationModuleClient(self),
|
||||
tls_edge_traffic_policy=TLSEdgeTrafficPolicyModuleClient(self),
|
||||
)
|
||||
|
||||
-2361
File diff suppressed because it is too large
Load Diff
-2668
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ def read_file(filename):
|
||||
|
||||
setup(
|
||||
name="ngrok-api",
|
||||
version="0.17.0",
|
||||
version="0.0.0",
|
||||
description="ngrok HTTP API client library",
|
||||
long_description=read_file("README.md"),
|
||||
long_description_content_type="text/markdown",
|
||||
|
||||
@@ -198,102 +198,7 @@ def test_event_subscriptions():
|
||||
mock.returns(None)
|
||||
ev_sub.delete()
|
||||
|
||||
def test_backends():
|
||||
c, mock = setup_api_client()
|
||||
|
||||
# create a 404 http response backend
|
||||
mock.returns(mock_backend_404)
|
||||
backend_404 = c.backends.http_response.create(description=description, body=body, status_code=status_code)
|
||||
assert backend_404.body == body
|
||||
assert backend_404.status_code == status_code
|
||||
|
||||
# create a tunnel group backend
|
||||
mock.returns(mock_backend_tg)
|
||||
backend_tg = c.backends.tunnel_group.create(description=description)
|
||||
assert backend_tg.description == description
|
||||
|
||||
# create a failover backend
|
||||
mock.returns(mock_backend_fo)
|
||||
backend_fo = c.backends.failover.create(description=description, backends=[backend_tg.id, backend_404.id])
|
||||
assert backend_fo.description == description
|
||||
|
||||
# delete all the backends
|
||||
mock.returns(None)
|
||||
backend_fo.delete()
|
||||
backend_tg.delete()
|
||||
backend_404.delete()
|
||||
|
||||
def test_tcp_edges():
|
||||
c, mock = setup_api_client()
|
||||
|
||||
backend_mutate = ngrok.datatypes.EndpointBackendMutate(c, {"enabled": True,
|
||||
"backend_id": "bkdtg_26ttrtQgoYT4wF0LbAPyCliCTHu"})
|
||||
|
||||
# create TCP edge
|
||||
mock.returns(mock_edge_tcp)
|
||||
tcp_edg = c.edges.tcp.create(hostports=["1.tcp.ngrok.io:20021"], backend=backend_mutate, description=description)
|
||||
assert tcp_edg.hostports == ["1.tcp.ngrok.io:20021"]
|
||||
assert tcp_edg.description == description
|
||||
|
||||
# list TCP edges
|
||||
mock.returns(f"""{{"tcp_edges": [{mock_edge_tcp}]}}""")
|
||||
c.edges.tcp.list()
|
||||
|
||||
# delete TCP edge
|
||||
mock.returns(None)
|
||||
tcp_edg.delete()
|
||||
|
||||
def test_tls_edges():
|
||||
c, mock = setup_api_client()
|
||||
|
||||
backend_mutate = ngrok.datatypes.EndpointBackendMutate(c, {"enabled": True,
|
||||
"backend_id": "bkdtg_26ttsZg57ucy3iShmgFeW5qnzR9"})
|
||||
|
||||
# create TLS edge
|
||||
mock.returns(mock_edge_tls)
|
||||
tls_edg = c.edges.tls.create(hostports=["utthvga8.ngrok.io:443"], backend=backend_mutate, description=description)
|
||||
assert tls_edg.hostports == ["utthvga8.ngrok.io:443"]
|
||||
assert tls_edg.description == description
|
||||
|
||||
# list TLS edges
|
||||
mock.returns(f"""{{"tls_edges": [{mock_edge_tls}]}}""")
|
||||
c.edges.tls.list()
|
||||
|
||||
# delete TLS edge
|
||||
mock.returns(None)
|
||||
tls_edg.delete()
|
||||
|
||||
def test_https_edges():
|
||||
c, mock = setup_api_client()
|
||||
|
||||
# create a https edge
|
||||
mock.returns(mock_edge_https)
|
||||
edg = c.edges.https.create(description=description)
|
||||
assert edg.description == description
|
||||
|
||||
# create a route with a failover backend attached to it
|
||||
# compression is also enabled
|
||||
backend_mutate = ngrok.datatypes.EndpointBackendMutate(c, {"enabled": True,
|
||||
"backend_id": "bkdfo_26tiVQge4Ae9qXVmjORlUUbY6FJ"})
|
||||
compression = ngrok.datatypes.EndpointCompression(c, {"enabled": True})
|
||||
mock.returns(mock_edge_route_https)
|
||||
rte = c.edges.https_routes.create(edge_id=edg.id, match_type="path_prefix", match="/", backend=backend_mutate,
|
||||
compression=compression)
|
||||
assert rte.match_type == "path_prefix"
|
||||
assert rte.match == "/"
|
||||
assert rte.compression is not None
|
||||
|
||||
# update the backend module
|
||||
mock.returns(mock_edge_route_https)
|
||||
c.edge_modules.https_edge_route_backend.replace(edge_id=edg.id, id=rte.id, module=backend_mutate)
|
||||
|
||||
# list https edges
|
||||
mock.returns(f"""{{"https_edges": [{mock_edge_https}]}}""")
|
||||
c.edges.https.list()
|
||||
|
||||
# delete https edge
|
||||
mock.returns(None)
|
||||
edg.delete()
|
||||
|
||||
description = "Test description"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user