|
39 | 39 | )
|
40 | 40 | from google.cloud.shell_v1.services.cloud_shell_service import CloudShellServiceClient
|
41 | 41 | from google.cloud.shell_v1.services.cloud_shell_service import transports
|
42 |
| -from google.cloud.shell_v1.services.cloud_shell_service.transports.base import ( |
43 |
| - _API_CORE_VERSION, |
44 |
| -) |
45 | 42 | from google.cloud.shell_v1.services.cloud_shell_service.transports.base import (
|
46 | 43 | _GOOGLE_AUTH_VERSION,
|
47 | 44 | )
|
|
52 | 49 | import google.auth
|
53 | 50 |
|
54 | 51 |
|
55 |
| -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: |
56 |
| -# - Delete all the api-core and auth "less than" test cases |
| 52 | +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively |
| 53 | +# through google-api-core: |
| 54 | +# - Delete the auth "less than" test cases |
57 | 55 | # - Delete these pytest markers (Make the "greater than or equal to" tests the default).
|
58 | 56 | requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
|
59 | 57 | packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
|
|
64 | 62 | reason="This test requires google-auth >= 1.25.0",
|
65 | 63 | )
|
66 | 64 |
|
67 |
| -requires_api_core_lt_1_26_0 = pytest.mark.skipif( |
68 |
| - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), |
69 |
| - reason="This test requires google-api-core < 1.26.0", |
70 |
| -) |
71 |
| - |
72 |
| -requires_api_core_gte_1_26_0 = pytest.mark.skipif( |
73 |
| - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), |
74 |
| - reason="This test requires google-api-core >= 1.26.0", |
75 |
| -) |
76 |
| - |
77 | 65 |
|
78 | 66 | def client_cert_source_callback():
|
79 | 67 | return b"cert bytes", b"key bytes"
|
@@ -137,6 +125,18 @@ def test_cloud_shell_service_client_from_service_account_info(client_class):
|
137 | 125 | assert client.transport._host == "cloudshell.googleapis.com:443"
|
138 | 126 |
|
139 | 127 |
|
| 128 | +@pytest.mark.parametrize( |
| 129 | + "client_class", [CloudShellServiceClient, CloudShellServiceAsyncClient,] |
| 130 | +) |
| 131 | +def test_cloud_shell_service_client_service_account_always_use_jwt(client_class): |
| 132 | + with mock.patch.object( |
| 133 | + service_account.Credentials, "with_always_use_jwt_access", create=True |
| 134 | + ) as use_jwt: |
| 135 | + creds = service_account.Credentials(None, None, None) |
| 136 | + client = client_class(credentials=creds) |
| 137 | + use_jwt.assert_called_with(True) |
| 138 | + |
| 139 | + |
140 | 140 | @pytest.mark.parametrize(
|
141 | 141 | "client_class", [CloudShellServiceClient, CloudShellServiceAsyncClient,]
|
142 | 142 | )
|
@@ -1522,7 +1522,6 @@ def test_cloud_shell_service_transport_auth_adc_old_google_auth(transport_class)
|
1522 | 1522 | (transports.CloudShellServiceGrpcAsyncIOTransport, grpc_helpers_async),
|
1523 | 1523 | ],
|
1524 | 1524 | )
|
1525 |
| -@requires_api_core_gte_1_26_0 |
1526 | 1525 | def test_cloud_shell_service_transport_create_channel(transport_class, grpc_helpers):
|
1527 | 1526 | # If credentials and host are not provided, the transport class should use
|
1528 | 1527 | # ADC credentials.
|
@@ -1551,79 +1550,6 @@ def test_cloud_shell_service_transport_create_channel(transport_class, grpc_help
|
1551 | 1550 | )
|
1552 | 1551 |
|
1553 | 1552 |
|
1554 |
| -@pytest.mark.parametrize( |
1555 |
| - "transport_class,grpc_helpers", |
1556 |
| - [ |
1557 |
| - (transports.CloudShellServiceGrpcTransport, grpc_helpers), |
1558 |
| - (transports.CloudShellServiceGrpcAsyncIOTransport, grpc_helpers_async), |
1559 |
| - ], |
1560 |
| -) |
1561 |
| -@requires_api_core_lt_1_26_0 |
1562 |
| -def test_cloud_shell_service_transport_create_channel_old_api_core( |
1563 |
| - transport_class, grpc_helpers |
1564 |
| -): |
1565 |
| - # If credentials and host are not provided, the transport class should use |
1566 |
| - # ADC credentials. |
1567 |
| - with mock.patch.object( |
1568 |
| - google.auth, "default", autospec=True |
1569 |
| - ) as adc, mock.patch.object( |
1570 |
| - grpc_helpers, "create_channel", autospec=True |
1571 |
| - ) as create_channel: |
1572 |
| - creds = ga_credentials.AnonymousCredentials() |
1573 |
| - adc.return_value = (creds, None) |
1574 |
| - transport_class(quota_project_id="octopus") |
1575 |
| - |
1576 |
| - create_channel.assert_called_with( |
1577 |
| - "cloudshell.googleapis.com:443", |
1578 |
| - credentials=creds, |
1579 |
| - credentials_file=None, |
1580 |
| - quota_project_id="octopus", |
1581 |
| - scopes=("https://www.googleapis.com/auth/cloud-platform",), |
1582 |
| - ssl_credentials=None, |
1583 |
| - options=[ |
1584 |
| - ("grpc.max_send_message_length", -1), |
1585 |
| - ("grpc.max_receive_message_length", -1), |
1586 |
| - ], |
1587 |
| - ) |
1588 |
| - |
1589 |
| - |
1590 |
| -@pytest.mark.parametrize( |
1591 |
| - "transport_class,grpc_helpers", |
1592 |
| - [ |
1593 |
| - (transports.CloudShellServiceGrpcTransport, grpc_helpers), |
1594 |
| - (transports.CloudShellServiceGrpcAsyncIOTransport, grpc_helpers_async), |
1595 |
| - ], |
1596 |
| -) |
1597 |
| -@requires_api_core_lt_1_26_0 |
1598 |
| -def test_cloud_shell_service_transport_create_channel_user_scopes( |
1599 |
| - transport_class, grpc_helpers |
1600 |
| -): |
1601 |
| - # If credentials and host are not provided, the transport class should use |
1602 |
| - # ADC credentials. |
1603 |
| - with mock.patch.object( |
1604 |
| - google.auth, "default", autospec=True |
1605 |
| - ) as adc, mock.patch.object( |
1606 |
| - grpc_helpers, "create_channel", autospec=True |
1607 |
| - ) as create_channel: |
1608 |
| - creds = ga_credentials.AnonymousCredentials() |
1609 |
| - adc.return_value = (creds, None) |
1610 |
| - |
1611 |
| - transport_class(quota_project_id="octopus", scopes=["1", "2"]) |
1612 |
| - |
1613 |
| - create_channel.assert_called_with( |
1614 |
| - "cloudshell.googleapis.com:443", |
1615 |
| - credentials=creds, |
1616 |
| - credentials_file=None, |
1617 |
| - quota_project_id="octopus", |
1618 |
| - scopes=["1", "2"], |
1619 |
| - ssl_credentials=None, |
1620 |
| - options=[ |
1621 |
| - ("grpc.max_send_message_length", -1), |
1622 |
| - ("grpc.max_receive_message_length", -1), |
1623 |
| - ], |
1624 |
| - ) |
1625 |
| - |
1626 |
| - |
1627 | 1553 | @pytest.mark.parametrize(
|
1628 | 1554 | "transport_class",
|
1629 | 1555 | [
|
|
0 commit comments