-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BED-4255: IssuancePolicy Nodes (#111)
* feat: add IssuancePolicy nodes * wip: testable searchresults * chore: revert framework * test: add some tests for GetLabel * feat: add issuancepolicy acl info * chore: update name set for issuancepolicy * feat: add issuancepolicy properties
- Loading branch information
Showing
12 changed files
with
171 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ public enum Label | |
RootCA, | ||
AIACA, | ||
EnterpriseCA, | ||
NTAuthStore | ||
NTAuthStore, | ||
IssuancePolicy | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.DirectoryServices.Protocols; | ||
using SharpHoundCommonLib; | ||
using BindingFlags = System.Reflection.BindingFlags; | ||
|
||
namespace CommonLibTest.Facades | ||
{ | ||
public class MockableSearchResultEntry | ||
{ | ||
public static SearchResultEntry Construct(Dictionary<string, object> values, string distinguishedName) | ||
{ | ||
var attributes = CreateAttributes(values); | ||
|
||
return CreateSearchResultEntry(attributes, distinguishedName); | ||
} | ||
|
||
|
||
private static SearchResultAttributeCollection CreateAttributes(Dictionary<string, object> values) | ||
{ | ||
var coll = | ||
(SearchResultAttributeCollection)typeof(SearchResultAttributeCollection) | ||
.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null) | ||
.Invoke(null); | ||
|
||
var dict = (IDictionary) typeof(SearchResultAttributeCollection).GetProperty("Dictionary", | ||
BindingFlags.NonPublic | BindingFlags.Instance).GetValue(coll); | ||
|
||
foreach (var v in values) | ||
{ | ||
dict.Add(v.Key, new DirectoryAttribute(v.Key, v.Value)); | ||
} | ||
return coll; | ||
} | ||
|
||
private static SearchResultEntry CreateSearchResultEntry(SearchResultAttributeCollection attributes, | ||
string distinguishedName) | ||
{ | ||
var types = new[] | ||
{ | ||
typeof(string), | ||
typeof(SearchResultAttributeCollection), | ||
}; | ||
|
||
var sre = (SearchResultEntry)typeof(SearchResultEntry) | ||
.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, types, null) | ||
.Invoke(new object[]{ distinguishedName, attributes}); | ||
|
||
return sre; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Collections.Generic; | ||
using System.Security.Principal; | ||
using CommonLibTest.Facades; | ||
using SharpHoundCommonLib; | ||
using SharpHoundCommonLib.Enums; | ||
using Xunit; | ||
|
||
namespace CommonLibTest | ||
{ | ||
public class SearchResultEntryTests | ||
{ | ||
[WindowsOnlyFact] | ||
public void Test_GetLabelIssuanceOIDObjects() | ||
{ | ||
var sid = new SecurityIdentifier("S-1-5-21-3130019616-2776909439-2417379446-500"); | ||
var bsid = new byte[sid.BinaryLength]; | ||
sid.GetBinaryForm(bsid, 0); | ||
var attribs = new Dictionary<string, object> | ||
{ | ||
{ "objectsid", bsid}, | ||
{ "objectclass", "msPKI-Enterprise-Oid" }, | ||
{ "flags", "2" } | ||
}; | ||
|
||
var sre = MockableSearchResultEntry.Construct(attribs, "CN=Test,CN=OID,CN=Public Key Services,CN=Services,CN=Configuration"); | ||
Assert.Equal(Label.IssuancePolicy, sre.GetLabel()); | ||
|
||
sre = MockableSearchResultEntry.Construct(attribs, "CN=OID,CN=Public Key Services,CN=Services,CN=Configuration"); | ||
Assert.Equal(Label.Container, sre.GetLabel()); | ||
} | ||
} | ||
} |