diff --git a/azure-graphrbac/HISTORY.rst b/azure-graphrbac/HISTORY.rst index c6ccc7352d88..8a1198528224 100644 --- a/azure-graphrbac/HISTORY.rst +++ b/azure-graphrbac/HISTORY.rst @@ -3,6 +3,13 @@ Release History =============== +0.51.0 (2018-10-11) ++++++++++++++++++++ + +**Features** + +- Add delete group/application owner + 0.50.0 (2018-10-10) +++++++++++++++++++ diff --git a/azure-graphrbac/azure/graphrbac/operations/applications_operations.py b/azure-graphrbac/azure/graphrbac/operations/applications_operations.py index 25750b9a580e..7740b9d7e6d3 100644 --- a/azure-graphrbac/azure/graphrbac/operations/applications_operations.py +++ b/azure-graphrbac/azure/graphrbac/operations/applications_operations.py @@ -467,6 +467,59 @@ def add_owner( return client_raw_response add_owner.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}/$links/owners'} + def remove_owner( + self, application_object_id, owner_object_id, custom_headers=None, raw=False, **operation_config): + """Remove a member from owners. + + :param application_object_id: The object ID of the application from + which to remove the owner. + :type application_object_id: str + :param owner_object_id: Owner object id + :type owner_object_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`GraphErrorException` + """ + # Construct URL + url = self.remove_owner.metadata['url'] + path_format_arguments = { + 'applicationObjectId': self._serialize.url("application_object_id", application_object_id, 'str'), + 'ownerObjectId': self._serialize.url("owner_object_id", owner_object_id, 'str'), + 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise models.GraphErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + remove_owner.metadata = {'url': '/{tenantID}/applications/{applicationObjectId}/$links/owners/{ownerObjectId}'} + def list_key_credentials( self, application_object_id, custom_headers=None, raw=False, **operation_config): """Get the keyCredentials associated with an application. diff --git a/azure-graphrbac/azure/graphrbac/operations/groups_operations.py b/azure-graphrbac/azure/graphrbac/operations/groups_operations.py index 52e7f22d8378..c9f18954ebe6 100644 --- a/azure-graphrbac/azure/graphrbac/operations/groups_operations.py +++ b/azure-graphrbac/azure/graphrbac/operations/groups_operations.py @@ -745,3 +745,56 @@ def add_owner( client_raw_response = ClientRawResponse(None, response) return client_raw_response add_owner.metadata = {'url': '/{tenantID}/groups/{objectId}/$links/owners'} + + def remove_owner( + self, object_id, owner_object_id, custom_headers=None, raw=False, **operation_config): + """Remove a member from owners. + + :param object_id: The object ID of the group from which to remove the + owner. + :type object_id: str + :param owner_object_id: Owner object id + :type owner_object_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`GraphErrorException` + """ + # Construct URL + url = self.remove_owner.metadata['url'] + path_format_arguments = { + 'objectId': self._serialize.url("object_id", object_id, 'str'), + 'ownerObjectId': self._serialize.url("owner_object_id", owner_object_id, 'str'), + 'tenantID': self._serialize.url("self.config.tenant_id", self.config.tenant_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise models.GraphErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + remove_owner.metadata = {'url': '/{tenantID}/groups/{objectId}/$links/owners/{ownerObjectId}'} diff --git a/azure-graphrbac/azure/graphrbac/version.py b/azure-graphrbac/azure/graphrbac/version.py index 1002e003856c..5f918f435103 100644 --- a/azure-graphrbac/azure/graphrbac/version.py +++ b/azure-graphrbac/azure/graphrbac/version.py @@ -9,5 +9,4 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.50.0" - +VERSION = "0.51.0" diff --git a/azure-graphrbac/tests/recordings/test_graphrbac.test_signed_in_user.yaml b/azure-graphrbac/tests/recordings/test_graphrbac.test_signed_in_user.yaml index d60bb82fd9d8..74d53726f7d2 100644 --- a/azure-graphrbac/tests/recordings/test_graphrbac.test_signed_in_user.yaml +++ b/azure-graphrbac/tests/recordings/test_graphrbac.test_signed_in_user.yaml @@ -3,62 +3,31 @@ interactions: body: null headers: Accept: [application/json] - Accept-Charset: [utf-8] Accept-Encoding: ['gzip, deflate'] Connection: [keep-alive] - User-Agent: [python-requests/2.19.1] - return-client-request-id: ['true'] - x-client-CPU: [x64] - x-client-OS: [win32] - x-client-SKU: [Python] - x-client-Ver: [1.0.1] - method: GET - uri: https://login.microsoftonline.com/common/UserRealm/admin2%40myaddomain.onmicrosoft.com?api-version=1.0 - response: - body: {string: '{"ver":"1.0","account_type":"Managed","domain_name":"myaddomain.onmicrosoft.com","cloud_instance_name":"microsoftonline.com","cloud_audience_urn":"urn:federation:MicrosoftOnline"}'} - headers: - cache-control: [private] - content-disposition: [inline; filename=userrealm.json] - content-length: ['181'] - content-type: [application/json; charset=utf-8] - date: ['Fri, 31 Aug 2018 17:17:50 GMT'] - p3p: [CP="DSP CUR OTPi IND OTRi ONL FIN"] - server: [Microsoft-IIS/10.0] - set-cookie: [x-ms-gateway-slice=019; path=/; secure; HttpOnly, stsservicecookie=ests; - path=/; secure; HttpOnly] - strict-transport-security: [max-age=31536000; includeSubDomains] - x-content-type-options: [nosniff] - status: {code: 200, message: OK} -- request: - body: null - headers: - Accept: [application/json] - Accept-Encoding: ['gzip, deflate'] - Connection: [keep-alive] - User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) msrest/0.5.4 msrest_azure/0.5.0 - azure-graphrbac/1.6 Azure-SDK-For-Python] + User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) msrest/0.6.0 msrest_azure/0.4.34 + azure-graphrbac/0.50.0 Azure-SDK-For-Python] accept-language: [en-US] method: GET uri: https://graph.windows.net/myaddomain.onmicrosoft.com/me?api-version=1.6 response: - body: {string: '{"odata.metadata":"https://graph.windows.net/myaddomain.onmicrosoft.com/$metadata#directoryObjects/Microsoft.DirectoryServices.User/@Element","odata.type":"Microsoft.DirectoryServices.User","objectType":"User","objectId":"5963f50c-7c43-405c-af7e-53294de76abd","deletionTimestamp":null,"accountEnabled":true,"ageGroup":null,"assignedLicenses":[{"disabledPlans":[],"skuId":"a403ebcc-fae0-4ca2-8c8c-7a907fd6c235"}],"assignedPlans":[{"assignedTimestamp":"2017-12-07T23:01:21Z","capabilityStatus":"Enabled","service":"AzureAnalysis","servicePlanId":"2049e525-b859-401b-b2a0-e0a31c4b1fe4"}],"city":null,"companyName":null,"consentProvidedForMinor":null,"country":null,"createdDateTime":"2016-01-06T17:18:25Z","creationType":null,"department":null,"dirSyncEnabled":null,"displayName":"Admin2","employeeId":null,"facsimileTelephoneNumber":null,"givenName":"Admin2","immutableId":null,"isCompromised":null,"jobTitle":null,"lastDirSyncTime":null,"legalAgeGroupClassification":null,"mail":null,"mailNickname":"admin2","mobile":null,"onPremisesDistinguishedName":null,"onPremisesSecurityIdentifier":null,"otherMails":["destanko@microsoft.com"],"passwordPolicies":"None","passwordProfile":null,"physicalDeliveryOfficeName":null,"postalCode":null,"preferredLanguage":"en-US","provisionedPlans":[],"provisioningErrors":[],"proxyAddresses":[],"refreshTokensValidFromDateTime":"2018-06-29T20:46:18Z","showInAddressList":null,"signInNames":[],"sipProxyAddress":null,"state":null,"streetAddress":null,"surname":"Admin2","telephoneNumber":null,"usageLocation":"US","userIdentities":[],"userPrincipalName":"admin2@AzureSDKTeam.onmicrosoft.com","userState":null,"userStateChangedOn":null,"userType":"Member"}'} + body: {string: '{"odata.metadata":"https://graph.windows.net/myaddomain.onmicrosoft.com/$metadata#directoryObjects/@Element","odata.type":"Microsoft.DirectoryServices.User","objectType":"User","objectId":"5963f50c-7c43-405c-af7e-53294de76abd","deletionTimestamp":null,"accountEnabled":true,"ageGroup":null,"assignedLicenses":[{"disabledPlans":[],"skuId":"a403ebcc-fae0-4ca2-8c8c-7a907fd6c235"}],"assignedPlans":[{"assignedTimestamp":"2017-12-07T23:01:21Z","capabilityStatus":"Enabled","service":"AzureAnalysis","servicePlanId":"2049e525-b859-401b-b2a0-e0a31c4b1fe4"}],"city":null,"companyName":null,"consentProvidedForMinor":null,"country":null,"createdDateTime":"2016-01-06T17:18:25Z","creationType":null,"department":null,"dirSyncEnabled":null,"displayName":"Admin2","employeeId":null,"facsimileTelephoneNumber":null,"givenName":"Admin2","immutableId":null,"isCompromised":null,"jobTitle":null,"lastDirSyncTime":null,"legalAgeGroupClassification":null,"mail":null,"mailNickname":"admin2","mobile":null,"onPremisesDistinguishedName":null,"onPremisesSecurityIdentifier":null,"otherMails":["destanko@microsoft.com"],"passwordPolicies":"None","passwordProfile":null,"physicalDeliveryOfficeName":null,"postalCode":null,"preferredLanguage":"en-US","provisionedPlans":[],"provisioningErrors":[],"proxyAddresses":[],"refreshTokensValidFromDateTime":"2018-10-10T16:31:56Z","showInAddressList":null,"signInNames":[],"sipProxyAddress":null,"state":null,"streetAddress":null,"surname":"Admin2","telephoneNumber":null,"thumbnailPhoto@odata.mediaEditLink":"directoryObjects/5963f50c-7c43-405c-af7e-53294de76abd/Microsoft.DirectoryServices.User/thumbnailPhoto","usageLocation":"US","userIdentities":[],"userPrincipalName":"admin2@AzureSDKTeam.onmicrosoft.com","userState":null,"userStateChangedOn":null,"userType":"Member"}'} headers: access-control-allow-origin: ['*'] cache-control: [no-cache] - content-length: ['1688'] + content-length: ['1796'] content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] dataserviceversion: [3.0;] - date: ['Fri, 31 Aug 2018 17:17:50 GMT'] - duration: ['932111'] + date: ['Thu, 11 Oct 2018 18:11:46 GMT'] + duration: ['361468'] expires: ['-1'] - ocp-aad-diagnostics-server-name: [8lVrSY0cb3yYmzhL1jb6bG/9VqDeaSkgeMUNwJzqewM=] - ocp-aad-session-key: [cDa-ek9Lolb50nplRWhB-xBqqyhOJbVnQSA0e59uX6BeaEjvMji3F3Xc3X32tbGGHpPofa5aOrvnQ6pkwI_fmsB4ZSvTpH1w8TIPfdF6kw29khc86yiZlBB-PZTTF7gUrfGnvyK3hlNAqoNWl9WYzg.YUT556XHRli9DN7enMGuisyKdnJoPP3enqjYHfzWidA] + ocp-aad-diagnostics-server-name: [Hmgcuy1hpGi6KCpCk4BrqM0RyCbBpwqDLCqIAEp//qg=] + ocp-aad-session-key: [FTuAD5yaSVAu8MDnc_KzoZsMPGBnLD4GkXwIgsOaiROri1l9c1O-3NH1T4Kr-AV4Ca6o6oxRxSBvnxhIJtBV3QPztC-hTv80WSbNxrUwBpXhlTB3oIQ2dxmp97aRXKPW2yFwwZ9VOklkF_3LXxgVVQ.qcNJ00teWhRqYam7YVj7bIUszWj7hy0F7jP0SVElA6Y] pragma: [no-cache] - request-id: [ec53ce44-1144-4a6c-8a13-1c05c939e62c] + request-id: [35aa08ab-05ad-4458-9351-73289661da11] server: [Microsoft-IIS/10.0] strict-transport-security: [max-age=31536000; includeSubDomains] x-aspnet-version: [4.0.30319] - x-content-type-options: [nosniff] x-ms-dirapi-data-contract-version: ['1.6'] x-powered-by: [ASP.NET] status: {code: 200, message: OK} @@ -71,27 +40,27 @@ interactions: Connection: [keep-alive] Content-Length: ['125'] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) msrest/0.5.4 msrest_azure/0.5.0 - azure-graphrbac/1.6 Azure-SDK-For-Python] + User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) msrest/0.6.0 msrest_azure/0.4.34 + azure-graphrbac/0.50.0 Azure-SDK-For-Python] accept-language: [en-US] method: POST uri: https://graph.windows.net/myaddomain.onmicrosoft.com/groups?api-version=1.6 response: - body: {string: '{"odata.metadata":"https://graph.windows.net/myaddomain.onmicrosoft.com/$metadata#directoryObjects/Microsoft.DirectoryServices.Group/@Element","odata.type":"Microsoft.DirectoryServices.Group","objectType":"Group","objectId":"5173c456-6909-482b-af5e-d2024caa9d1e","deletionTimestamp":null,"description":null,"dirSyncEnabled":null,"displayName":"pytestgroup_display","lastDirSyncTime":null,"mail":null,"mailNickname":"pytestgroup_nickname","mailEnabled":false,"onPremisesDomainName":null,"onPremisesNetBiosName":null,"onPremisesSamAccountName":null,"onPremisesSecurityIdentifier":null,"provisioningErrors":[],"proxyAddresses":[],"securityEnabled":true}'} + body: {string: '{"odata.metadata":"https://graph.windows.net/myaddomain.onmicrosoft.com/$metadata#directoryObjects/Microsoft.DirectoryServices.Group/@Element","odata.type":"Microsoft.DirectoryServices.Group","objectType":"Group","objectId":"537cef66-0503-4a1c-a2b6-a6958106e355","deletionTimestamp":null,"description":null,"dirSyncEnabled":null,"displayName":"pytestgroup_display","lastDirSyncTime":null,"mail":null,"mailNickname":"pytestgroup_nickname","mailEnabled":false,"onPremisesDomainName":null,"onPremisesNetBiosName":null,"onPremisesSamAccountName":null,"onPremisesSecurityIdentifier":null,"provisioningErrors":[],"proxyAddresses":[],"securityEnabled":true}'} headers: access-control-allow-origin: ['*'] cache-control: [no-cache] content-length: ['652'] content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] dataserviceversion: [3.0;] - date: ['Fri, 31 Aug 2018 17:17:52 GMT'] - duration: ['10438917'] + date: ['Thu, 11 Oct 2018 18:11:47 GMT'] + duration: ['1894328'] expires: ['-1'] - location: ['https://graph.windows.net/myaddomain.onmicrosoft.com/directoryObjects/5173c456-6909-482b-af5e-d2024caa9d1e/Microsoft.DirectoryServices.Group'] - ocp-aad-diagnostics-server-name: [y2AFatDb8bxovAuAcAg+Xai78XOhksqhh+LYGhHC+p8=] - ocp-aad-session-key: [AfET1pkeY8P5rhg-XpwxcCoEP_13SlwQQONmV5Qk0wP-YnxcNYyAjaBH8ON_hLM2GFpxxLxVRdL8UWdhFjKC7LhXLNw00-AmkENz_ePy1WKHun-yIma2H4pNFQbRas4-QxB2OHzXyQIvxHSRaUHmMw.GOCEjevJmncwyaaA4vFc8cob8vmBAitXedaJPka9TuQ] + location: ['https://graph.windows.net/myaddomain.onmicrosoft.com/directoryObjects/537cef66-0503-4a1c-a2b6-a6958106e355/Microsoft.DirectoryServices.Group'] + ocp-aad-diagnostics-server-name: [zPeOuJeNLZ5N5CAKU8XN6jsJ5sC6cSv6Gh6WpNy3E8g=] + ocp-aad-session-key: [ozuRYmXz3J04O2uMObVlFxbApVC8UQIdOs4znqQJwL8aqypzNeSpNHfNyTO000_amh5tJiPko_DhBgV2dm9agOCz66gZDPSN4ulOrZKBDf0HRcUk7PWALcXmujgTrvmJf6aQ-cpbgo_ZiOLhBtqifA.yiHydYJziSQlcNrXzsZesls6DoD6vdod_KyY6Oz_ayE] pragma: [no-cache] - request-id: [0e39bb45-d9c0-41bc-a938-6f30ce2024b9] + request-id: [17c8bf1f-dac3-419f-bf69-745ddab0707a] server: [Microsoft-IIS/10.0] strict-transport-security: [max-age=31536000; includeSubDomains] x-aspnet-version: [4.0.30319] @@ -107,24 +76,24 @@ interactions: Connection: [keep-alive] Content-Length: ['119'] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) msrest/0.5.4 msrest_azure/0.5.0 - azure-graphrbac/1.6 Azure-SDK-For-Python] + User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) msrest/0.6.0 msrest_azure/0.4.34 + azure-graphrbac/0.50.0 Azure-SDK-For-Python] accept-language: [en-US] method: POST - uri: https://graph.windows.net/myaddomain.onmicrosoft.com/groups/5173c456-6909-482b-af5e-d2024caa9d1e/$links/owners?api-version=1.6 + uri: https://graph.windows.net/myaddomain.onmicrosoft.com/groups/537cef66-0503-4a1c-a2b6-a6958106e355/$links/owners?api-version=1.6 response: body: {string: ''} headers: access-control-allow-origin: ['*'] cache-control: [no-cache] dataserviceversion: [1.0;] - date: ['Fri, 31 Aug 2018 17:17:53 GMT'] - duration: ['2418588'] + date: ['Thu, 11 Oct 2018 18:11:48 GMT'] + duration: ['2061877'] expires: ['-1'] - ocp-aad-diagnostics-server-name: [wL7zcXvhIXIAGeynkORCtbz/3bweluE/NT+Ij6AZJG0=] - ocp-aad-session-key: [jsevURDRXCXCtUkhbwIME8U4IzvEZiOaiJuQpZLjM_LYw25N-6TP8zjvjiookf8aiJVVaJnkN6BBn9cgIKzZDFpfz6YH-dwc8eVGYbcEn1ukLK3rsuoz9UlFpTrBD9jWdquSnp4b6AdkjazM_CUy4A.fYt2qCpc3F2NOfWCuMD-Ao5NLhaFSIxVirGkUM8CxPg] + ocp-aad-diagnostics-server-name: [NecIdAbtcl2G5DavAD0ay+NyJ0bZ8m4qvkKAOpQmV0w=] + ocp-aad-session-key: [kfyS95haI3IP_UXPP20oeR0WsKXbc5ts_1jVXH2cu77zTZLnMjyA4uArAOWciBwcmuweAVO6jlSbyYp__4uuBLvvpuLg346jvL8Czhn7P3QVv8KEo1olM6GwFS8WBHVTto60sk8MbLrEAA5A8A9yQg.lJsdw-rKNIU60fyV0DkYGF-4DDZWEly7aL7ha7KLbqs] pragma: [no-cache] - request-id: [7744627e-0be4-48ff-8856-f2b1852a75ee] + request-id: [4f4d1591-98a2-4ee1-a2a1-0afb57905f01] server: [Microsoft-IIS/10.0] strict-transport-security: [max-age=31536000; includeSubDomains] x-aspnet-version: [4.0.30319] @@ -138,35 +107,34 @@ interactions: Accept: [application/json] Accept-Encoding: ['gzip, deflate'] Connection: [keep-alive] - User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) msrest/0.5.4 msrest_azure/0.5.0 - azure-graphrbac/1.6 Azure-SDK-For-Python] + User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) msrest/0.6.0 msrest_azure/0.4.34 + azure-graphrbac/0.50.0 Azure-SDK-For-Python] accept-language: [en-US] method: GET uri: https://graph.windows.net/myaddomain.onmicrosoft.com/me/ownedObjects?api-version=1.6 response: body: {string: '{"odata.metadata":"https://graph.windows.net/myaddomain.onmicrosoft.com/$metadata#directoryObjects","value":[{"odata.type":"Microsoft.DirectoryServices.Group","objectType":"Group","objectId":"8a9b1617-fc8d-4aa9-a42f-99868d314699","deletionTimestamp":null,"description":"first - group","dirSyncEnabled":null,"displayName":"firstgroup","lastDirSyncTime":null,"mail":null,"mailNickname":"0afc6ff5-b63b-4583-b7f0-6a639e64cc75","mailEnabled":false,"onPremisesDomainName":null,"onPremisesNetBiosName":null,"onPremisesSamAccountName":null,"onPremisesSecurityIdentifier":null,"provisioningErrors":[],"proxyAddresses":[],"securityEnabled":true},{"odata.type":"Microsoft.DirectoryServices.Application","objectType":"Application","objectId":"b48ab268-479a-4640-aa87-021e92ae2626","deletionTimestamp":null,"acceptMappedClaims":null,"addIns":[],"appId":"d5938293-ffce-440e-ae1e-92c0a569e1e4","appRoles":[],"availableToOtherTenants":false,"displayName":"cormazuresdkapp","errorUrl":null,"groupMembershipClaims":null,"homepage":"http://cormazuresdkapp","identifierUris":["https://AzureSDKTeam.onmicrosoft.com/fc187aa3-4458-4d6e-a4dc-bb5b07f68ea8"],"informationalUrls":{"termsOfService":null,"support":null,"privacy":null,"marketing":null},"isDeviceOnlyAuthSupported":null,"keyCredentials":[],"knownClientApplications":[],"logoutUrl":null,"logoUrl":null,"oauth2AllowIdTokenImplicitFlow":true,"oauth2AllowImplicitFlow":false,"oauth2AllowUrlPathMatching":false,"oauth2Permissions":[{"adminConsentDescription":"Allow + group","dirSyncEnabled":null,"displayName":"firstgroup","lastDirSyncTime":null,"mail":null,"mailNickname":"0afc6ff5-b63b-4583-b7f0-6a639e64cc75","mailEnabled":false,"onPremisesDomainName":null,"onPremisesNetBiosName":null,"onPremisesSamAccountName":null,"onPremisesSecurityIdentifier":null,"provisioningErrors":[],"proxyAddresses":[],"securityEnabled":true},{"odata.type":"Microsoft.DirectoryServices.Application","objectType":"Application","objectId":"b48ab268-479a-4640-aa87-021e92ae2626","deletionTimestamp":null,"acceptMappedClaims":null,"addIns":[],"appId":"d5938293-ffce-440e-ae1e-92c0a569e1e4","appRoles":[],"availableToOtherTenants":false,"displayName":"cormazuresdkapp","errorUrl":null,"groupMembershipClaims":null,"homepage":"http://cormazuresdkapp","identifierUris":["https://AzureSDKTeam.onmicrosoft.com/fc187aa3-4458-4d6e-a4dc-bb5b07f68ea8"],"informationalUrls":{"termsOfService":null,"support":null,"privacy":null,"marketing":null},"isDeviceOnlyAuthSupported":null,"keyCredentials":[],"knownClientApplications":[],"logoutUrl":null,"logo@odata.mediaEditLink":"directoryObjects/b48ab268-479a-4640-aa87-021e92ae2626/Microsoft.DirectoryServices.Application/logo","logoUrl":null,"mainLogo@odata.mediaEditLink":"directoryObjects/b48ab268-479a-4640-aa87-021e92ae2626/Microsoft.DirectoryServices.Application/mainLogo","oauth2AllowIdTokenImplicitFlow":true,"oauth2AllowImplicitFlow":false,"oauth2AllowUrlPathMatching":false,"oauth2Permissions":[{"adminConsentDescription":"Allow the application to access cormazuresdkapp on behalf of the signed-in user.","adminConsentDisplayName":"Access cormazuresdkapp","id":"17083250-6cfd-4d23-b3c8-f4293c7aab44","isEnabled":true,"type":"User","userConsentDescription":"Allow the application to access cormazuresdkapp on your behalf.","userConsentDisplayName":"Access - cormazuresdkapp","value":"user_impersonation"}],"oauth2RequirePostResponse":false,"optionalClaims":null,"orgRestrictions":[],"parentalControlSettings":{"countriesBlockedForMinors":[],"legalAgeGroupRule":"Allow"},"passwordCredentials":[],"publicClient":false,"publisherDomain":null,"recordConsentConditions":null,"replyUrls":["http://cormazuresdkapp"],"requiredResourceAccess":[{"resourceAppId":"00000002-0000-0000-c000-000000000000","resourceAccess":[{"id":"311a71cc-e848-46a1-bdf8-97ff7156d8e6","type":"Scope"}]}],"samlMetadataUrl":null,"signInAudience":null,"tokenEncryptionKeyId":null},{"odata.type":"Microsoft.DirectoryServices.Group","objectType":"Group","objectId":"5173c456-6909-482b-af5e-d2024caa9d1e","deletionTimestamp":null,"description":null,"dirSyncEnabled":null,"displayName":"pytestgroup_display","lastDirSyncTime":null,"mail":null,"mailNickname":"pytestgroup_nickname","mailEnabled":false,"onPremisesDomainName":null,"onPremisesNetBiosName":null,"onPremisesSamAccountName":null,"onPremisesSecurityIdentifier":null,"provisioningErrors":[],"proxyAddresses":[],"securityEnabled":true}]}'} + cormazuresdkapp","value":"user_impersonation"}],"oauth2RequirePostResponse":false,"optionalClaims":null,"orgRestrictions":[],"parentalControlSettings":{"countriesBlockedForMinors":[],"legalAgeGroupRule":"Allow"},"passwordCredentials":[],"publicClient":false,"publisherDomain":null,"recordConsentConditions":null,"replyUrls":["http://cormazuresdkapp"],"requiredResourceAccess":[{"resourceAppId":"00000002-0000-0000-c000-000000000000","resourceAccess":[{"id":"311a71cc-e848-46a1-bdf8-97ff7156d8e6","type":"Scope"}]}],"samlMetadataUrl":null,"signInAudience":null,"tokenEncryptionKeyId":null},{"odata.type":"Microsoft.DirectoryServices.Group","objectType":"Group","objectId":"537cef66-0503-4a1c-a2b6-a6958106e355","deletionTimestamp":null,"description":null,"dirSyncEnabled":null,"displayName":"pytestgroup_display","lastDirSyncTime":null,"mail":null,"mailNickname":"pytestgroup_nickname","mailEnabled":false,"onPremisesDomainName":null,"onPremisesNetBiosName":null,"onPremisesSamAccountName":null,"onPremisesSecurityIdentifier":null,"provisioningErrors":[],"proxyAddresses":[],"securityEnabled":true}]}'} headers: access-control-allow-origin: ['*'] cache-control: [no-cache] - content-length: ['2923'] + content-length: ['3187'] content-type: [application/json; odata=minimalmetadata; streaming=true; charset=utf-8] dataserviceversion: [3.0;] - date: ['Fri, 31 Aug 2018 17:17:53 GMT'] - duration: ['1929073'] + date: ['Thu, 11 Oct 2018 18:11:48 GMT'] + duration: ['467986'] expires: ['-1'] - ocp-aad-diagnostics-server-name: [u84kEvNmBHxW4/vtHqUleUYQGGbAjaquR19gMFnyQJs=] - ocp-aad-session-key: [ivjStMztFbxuYvDtaNKERTKWmib-2_rH-hgSluH5l1ROZD3Ld4BQfIFbgkv6Ty4W2Mk9eXCx-Ae75JroLPA0Hao4_v3j4fCCkQzyjgYgJKqHyfpbi7SAzKu2iLpiK7EDpFCh0PhpSxtnAHhzi4-hWw.0GamIfYHT-lsNfz18RCpp1d3fPnnyZtw0q44Xm6qk8s] + ocp-aad-diagnostics-server-name: [IvZLzCWcIFkxniLh6wneapEsVoTEBBYbEdFPeHsJSbc=] + ocp-aad-session-key: [pcnTvyAR10Cr9l58vygoDTGfTJ5k0Pi-sUQI79wodAsExQYVjUD-GUi5Js0-e6AhPAbdkz-OmgH3KTXZXAWMozI2yRI3-Nz-sq_jW92gwn6loJGZ1RFrq__AK_JbRvZ32TE-w4uwXCWnLRB2pFZTgg.Lh6bhCgkhtHXLoJoq0AHO3OAPOIOMHr4rKB2NINva14] pragma: [no-cache] - request-id: [f75d38be-5229-4146-8e1a-985e6870feaf] + request-id: [2e48205f-dac7-4b15-a225-bc4f676248a2] server: [Microsoft-IIS/10.0] strict-transport-security: [max-age=31536000; includeSubDomains] x-aspnet-version: [4.0.30319] - x-content-type-options: [nosniff] x-ms-dirapi-data-contract-version: ['1.6'] x-powered-by: [ASP.NET] status: {code: 200, message: OK} @@ -177,24 +145,55 @@ interactions: Accept-Encoding: ['gzip, deflate'] Connection: [keep-alive] Content-Length: ['0'] - User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) msrest/0.5.4 msrest_azure/0.5.0 - azure-graphrbac/1.6 Azure-SDK-For-Python] + User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) msrest/0.6.0 msrest_azure/0.4.34 + azure-graphrbac/0.50.0 Azure-SDK-For-Python] + accept-language: [en-US] + method: DELETE + uri: https://graph.windows.net/myaddomain.onmicrosoft.com/groups/537cef66-0503-4a1c-a2b6-a6958106e355/$links/owners/5963f50c-7c43-405c-af7e-53294de76abd?api-version=1.6 + response: + body: {string: '{"odata.error":{"code":"Request_BadRequest","message":{"lang":"en","value":"The + group must have at least one owner, hence this owner cannot be removed."},"date":"2018-10-11T18:11:49","requestId":"041e7edc-b43a-40a1-a09f-7bb7f50bf52f","values":null}}'} + headers: + access-control-allow-origin: ['*'] + cache-control: [private] + content-length: ['249'] + content-type: [application/json; odata=minimalmetadata; charset=utf-8] + date: ['Thu, 11 Oct 2018 18:11:49 GMT'] + duration: ['547491'] + ocp-aad-diagnostics-server-name: [NecIdAbtcl2G5DavAD0ay+NyJ0bZ8m4qvkKAOpQmV0w=] + ocp-aad-session-key: [n8LsltdLLxswpn_9r80QBmZks8bt9ysACyUptkICE6lA9u1G0gRXP2ThTW-YsK6VTHY2T5twpgtlNZCaUAKagIWtgTHTITEZCiX__QozY0fD-kX_9Qy81TTd9VUDmeycRAjN6AOKiHDG93tVwq1A7g.ziQAFN7cCWLdq-ylYi-pVZ9Irs_lviAhN3fNGVcN_Ko] + request-id: [041e7edc-b43a-40a1-a09f-7bb7f50bf52f] + server: [Microsoft-IIS/10.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-aspnet-version: [4.0.30319] + x-ms-dirapi-data-contract-version: ['1.6'] + x-powered-by: [ASP.NET] + status: {code: 400, message: Bad Request} +- request: + body: null + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) msrest/0.6.0 msrest_azure/0.4.34 + azure-graphrbac/0.50.0 Azure-SDK-For-Python] accept-language: [en-US] method: DELETE - uri: https://graph.windows.net/myaddomain.onmicrosoft.com/groups/5173c456-6909-482b-af5e-d2024caa9d1e?api-version=1.6 + uri: https://graph.windows.net/myaddomain.onmicrosoft.com/groups/537cef66-0503-4a1c-a2b6-a6958106e355?api-version=1.6 response: body: {string: ''} headers: access-control-allow-origin: ['*'] cache-control: [no-cache] dataserviceversion: [1.0;] - date: ['Fri, 31 Aug 2018 17:17:53 GMT'] - duration: ['2285040'] + date: ['Thu, 11 Oct 2018 18:11:50 GMT'] + duration: ['3153263'] expires: ['-1'] - ocp-aad-diagnostics-server-name: [iBLPAV+mEu1yabKxR7hiHLRXeq9pAO/IjS9ArC3QLLk=] - ocp-aad-session-key: [XaWAcIulba2Vm5YR3RscO6HervDHvfSIC0POSTOehwQ2gwnzVBiGOGc-nbtOuW9hpdukhEu3YuyNfHJhTRix4XrdBbAhxiKhyjNl6llNubVJnJ-vLQa2UOosmBsRkU5d8z7MZQBsFHX2okolQsVLUQ.mKJLHhDAroANP8Y4QoktuSmnLERvqa_LErYpxWbc9L4] + ocp-aad-diagnostics-server-name: [YPT0bBpwREL5IJMIvN9GoYV1GS3mAXpIf09yabKcdz0=] + ocp-aad-session-key: [A_ccF75B-1W_ehwSbcEokBU3sFgBNdfaVp3fPPfTOg36QxNQNNiE3xc4A-rmSec8Q_WE7z_Oq_PdkCvWAMVzUlWo6fpPMLCnf-8IcPhwsFjRcBhSGdi2S1QuGqw4kGQMgAJYh0vf6zIIJOYA2dRBgg.cZZrJFvO-CRKaXgYhhPMnzfdL--vpcbx5Zb0skHFR8c] pragma: [no-cache] - request-id: [9f5f69e8-be4e-4a23-8e2c-928a0a36a38f] + request-id: [8a84f892-fdf4-4e42-a197-c9e923d5d2e3] server: [Microsoft-IIS/10.0] strict-transport-security: [max-age=31536000; includeSubDomains] x-aspnet-version: [4.0.30319] diff --git a/azure-graphrbac/tests/test_graphrbac.py b/azure-graphrbac/tests/test_graphrbac.py index cb0e2dd899e7..f1fa07b04785 100644 --- a/azure-graphrbac/tests/test_graphrbac.py +++ b/azure-graphrbac/tests/test_graphrbac.py @@ -7,7 +7,7 @@ #-------------------------------------------------------------------------- import unittest -import azure.graphrbac +import azure.graphrbac.models from devtools_testutils import AzureMgmtTestCase import pytest @@ -54,6 +54,15 @@ def test_signed_in_user(self): else: pytest.fail("Didn't found the group I just created in my owned objects") + try: + self.graphrbac_client.groups.remove_owner( + group.object_id, + user.object_id + ) + pytest.fail("Remove the only owner MUST fail") + except azure.graphrbac.models.GraphErrorException as err: + assert "The group must have at least one owner, hence this owner cannot be removed." in err.message + finally: if group: self.graphrbac_client.groups.delete(group.object_id)