Skip to content

Commit 725cee0

Browse files
committed
Storage/STG93 Add UserPrincipalName support for GetAccessControlList (Azure#5287)
* add upn support for get acl * add test record
1 parent afa20d9 commit 725cee0

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

sdk/storage/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "cpp",
44
"TagPrefix": "cpp/storage",
5-
"Tag": "cpp/storage_56979c9851"
5+
"Tag": "cpp/storage_96b65030ae"
66
}

sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_options.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,15 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
787787
* Specify the access condition for the path.
788788
*/
789789
PathAccessConditions AccessConditions;
790+
791+
/**
792+
* Valid only when Hierarchical Namespace is enabled for the account. If "true", the user
793+
* identity values returned in the owner and group fields of each list entry will be transformed
794+
* from Azure Active Directory Object IDs to User Principal Names. If "false", the values will
795+
* be returned as Azure Active Directory Object IDs. The default value is false. Note that group
796+
* and application Object IDs are not translated because they do not have unique friendly names.
797+
*/
798+
Nullable<bool> UserPrincipalName;
790799
};
791800

792801
/**

sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
421421
protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch;
422422
protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince;
423423
protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince;
424+
protocolLayerOptions.Upn = options.UserPrincipalName;
424425
auto response = _detail::PathClient::GetAccessControlList(
425426
*m_pipeline, m_pathUrl, protocolLayerOptions, _internal::WithReplicaStatus(context));
426427
Azure::Nullable<std::vector<Models::Acl>> acl;

sdk/storage/azure-storage-files-datalake/test/ut/datalake_path_client_test.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,40 @@ namespace Azure { namespace Storage { namespace Test {
522522
EXPECT_NE(it, acls.end());
523523
}
524524

525+
TEST_F(DataLakePathClientTest, GetAccessControlListWithUserPrincipalName)
526+
{
527+
std::string userPrincipalName = "[email protected]";
528+
std::string userObjectId = "72a3f86f-271f-439e-b031-25678907d381";
529+
std::vector<Files::DataLake::Models::Acl> acls;
530+
Files::DataLake::Models::Acl acl;
531+
acl.Type = "user";
532+
acl.Id = userObjectId;
533+
acl.Permissions = "rwx";
534+
acls.emplace_back(acl);
535+
m_pathClient->SetAccessControlList(acls);
536+
Files::DataLake::GetPathAccessControlListOptions options;
537+
538+
// UserPrincipalName = true
539+
options.UserPrincipalName = true;
540+
auto properties = m_pathClient->GetAccessControlList(options).Value;
541+
ASSERT_TRUE(!properties.Acls.empty());
542+
// Validate that the user principal name is returned
543+
acls = properties.Acls;
544+
auto it = std::find_if(
545+
acls.begin(), acls.end(), [&](const auto& acl) { return acl.Id == userPrincipalName; });
546+
EXPECT_NE(it, acls.end());
547+
548+
// UserPrincipalName = false
549+
options.UserPrincipalName = false;
550+
properties = m_pathClient->GetAccessControlList(options).Value;
551+
ASSERT_TRUE(!properties.Acls.empty());
552+
// Validate that the user principal name is returned
553+
acls = properties.Acls;
554+
it = std::find_if(
555+
acls.begin(), acls.end(), [&](const auto& acl) { return acl.Id == userObjectId; });
556+
EXPECT_NE(it, acls.end());
557+
}
558+
525559
TEST_F(DataLakePathClientTest, Audience)
526560
{
527561
auto credential = std::make_shared<Azure::Identity::ClientSecretCredential>(

0 commit comments

Comments
 (0)