Send feedback
Class MockIAMConnection (2.34.0-rc)
Stay organized with collections
Save and categorize content based on your preferences.
Version 2.34.0-rc keyboard_arrow_down
A class to mock IAMConnection
.
Application developers may want to test their code with simulated responses, including errors, from an object of type IAMClient
. To do so, construct an object of type IAMClient
with an instance of this class. Then use the Google Test framework functions to program the behavior of this mock.
See Also
This example for how to test your application with GoogleTest. While the example showcases types from the BigQuery library, the underlying principles apply for any pair of *Client
and *Connection
.
Functions
virtual options()
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Returns
Type
Description
Options
virtual ListServiceAccounts(google::iam::admin::v1::ListServiceAccountsRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::ListServiceAccountsRequest
Returns
Type
Description
StreamRange< google::iam::admin::v1::ServiceAccount >
virtual GetServiceAccount(google::iam::admin::v1::GetServiceAccountRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::GetServiceAccountRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::ServiceAccount >
virtual CreateServiceAccount(google::iam::admin::v1::CreateServiceAccountRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::CreateServiceAccountRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::ServiceAccount >
virtual PatchServiceAccount(google::iam::admin::v1::PatchServiceAccountRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::PatchServiceAccountRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::ServiceAccount >
virtual DeleteServiceAccount(google::iam::admin::v1::DeleteServiceAccountRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::DeleteServiceAccountRequest const &
Returns
Type
Description
Status
virtual UndeleteServiceAccount(google::iam::admin::v1::UndeleteServiceAccountRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::UndeleteServiceAccountRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::UndeleteServiceAccountResponse >
virtual EnableServiceAccount(google::iam::admin::v1::EnableServiceAccountRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::EnableServiceAccountRequest const &
Returns
Type
Description
Status
virtual DisableServiceAccount(google::iam::admin::v1::DisableServiceAccountRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::DisableServiceAccountRequest const &
Returns
Type
Description
Status
virtual ListServiceAccountKeys(google::iam::admin::v1::ListServiceAccountKeysRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::ListServiceAccountKeysRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::ListServiceAccountKeysResponse >
virtual GetServiceAccountKey(google::iam::admin::v1::GetServiceAccountKeyRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::GetServiceAccountKeyRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::ServiceAccountKey >
virtual CreateServiceAccountKey(google::iam::admin::v1::CreateServiceAccountKeyRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::CreateServiceAccountKeyRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::ServiceAccountKey >
virtual UploadServiceAccountKey(google::iam::admin::v1::UploadServiceAccountKeyRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::UploadServiceAccountKeyRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::ServiceAccountKey >
virtual DeleteServiceAccountKey(google::iam::admin::v1::DeleteServiceAccountKeyRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::DeleteServiceAccountKeyRequest const &
Returns
Type
Description
Status
virtual DisableServiceAccountKey(google::iam::admin::v1::DisableServiceAccountKeyRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::DisableServiceAccountKeyRequest const &
Returns
Type
Description
Status
virtual EnableServiceAccountKey(google::iam::admin::v1::EnableServiceAccountKeyRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::EnableServiceAccountKeyRequest const &
Returns
Type
Description
Status
virtual GetIamPolicy(google::iam::v1::GetIamPolicyRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::v1::GetIamPolicyRequest const &
Returns
Type
Description
StatusOr< google::iam::v1::Policy >
virtual SetIamPolicy(google::iam::v1::SetIamPolicyRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::v1::SetIamPolicyRequest const &
Returns
Type
Description
StatusOr< google::iam::v1::Policy >
virtual TestIamPermissions(google::iam::v1::TestIamPermissionsRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::v1::TestIamPermissionsRequest const &
Returns
Type
Description
StatusOr< google::iam::v1::TestIamPermissionsResponse >
virtual QueryGrantableRoles(google::iam::admin::v1::QueryGrantableRolesRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::QueryGrantableRolesRequest
Returns
Type
Description
StreamRange< google::iam::admin::v1::Role >
virtual ListRoles(google::iam::admin::v1::ListRolesRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::ListRolesRequest
Returns
Type
Description
StreamRange< google::iam::admin::v1::Role >
virtual GetRole(google::iam::admin::v1::GetRoleRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::GetRoleRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::Role >
virtual CreateRole(google::iam::admin::v1::CreateRoleRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::CreateRoleRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::Role >
virtual UpdateRole(google::iam::admin::v1::UpdateRoleRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::UpdateRoleRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::Role >
virtual DeleteRole(google::iam::admin::v1::DeleteRoleRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::DeleteRoleRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::Role >
virtual UndeleteRole(google::iam::admin::v1::UndeleteRoleRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::UndeleteRoleRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::Role >
virtual QueryTestablePermissions(google::iam::admin::v1::QueryTestablePermissionsRequest)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::QueryTestablePermissionsRequest
Returns
Type
Description
StreamRange< google::iam::admin::v1::Permission >
virtual QueryAuditableServices(google::iam::admin::v1::QueryAuditableServicesRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::QueryAuditableServicesRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::QueryAuditableServicesResponse >
virtual LintPolicy(google::iam::admin::v1::LintPolicyRequest const &)
This function is implemented using gMock 's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Parameter
Name
Description
request
google::iam::admin::v1::LintPolicyRequest const &
Returns
Type
Description
StatusOr< google::iam::admin::v1::LintPolicyResponse >
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-21 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-21 UTC."],[[["This page provides documentation for the `MockIAMConnection` class, which is designed for simulating responses and errors from an `IAMClient` in testing environments."],["The `MockIAMConnection` class supports mocking a wide range of IAM operations, including managing service accounts, service account keys, roles, and permissions."],["This mock class utilizes Google Test's gMock framework to allow application developers to easily program the behavior of the mock within their tests."],["The documentation lists different versions of the class, ranging from version 2.11.0 up to the latest release candidate 2.37.0-rc."],["A link to an example is provided in the documentation to show how you would use a similar mocking class in your unit tests, and demonstrates how it is used with the google test framework."]]],[]]