Skip to content

Commit

Permalink
Adds support for recoveryPhone, recoveryEmail, gender, and locations …
Browse files Browse the repository at this point in the history
…attributes
  • Loading branch information
ryannewington committed Jul 6, 2021
1 parent f0c70bd commit 24d49d1
Show file tree
Hide file tree
Showing 10 changed files with 297 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@
<HintPath>..\packages\Google.GData.Extensions.2.2.0.0\lib\Google.GData.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Lithnet.GoogleApps, Version=1.0.7771.31436, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lithnet.GoogleApps.1.0.7771.31436\lib\net452\Lithnet.GoogleApps.dll</HintPath>
<Reference Include="Lithnet.GoogleApps, Version=1.0.7845.21613, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lithnet.GoogleApps.1.0.7845.21613\lib\net452\Lithnet.GoogleApps.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Lithnet.Licensing.Core, Version=1.0.7772.24409, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lithnet.Licensing.Core.1.0.7772.24409\lib\netstandard2.0\Lithnet.Licensing.Core.dll</HintPath>
Expand Down
23 changes: 23 additions & 0 deletions src/Lithnet.GoogleApps.MA.UnitTests/TestParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,29 @@ public ILicenseManager<Features, Skus> LicenseManager
}
}

public IEnumerable<string> LocationsAttributeFixedTypes
{
get
{
yield return "default";
yield return "desk";
yield return "office";
yield return "home";
}
}

public IEnumerable<string> KeywordsAttributeFixedTypes
{
get
{
yield return "mission";
yield return "occupation";
yield return "outlook";
yield return "mykeywords";
}
}


public event EventHandler OnLicenseDataChanged;

public string GetRawLicenseData()
Expand Down
50 changes: 44 additions & 6 deletions src/Lithnet.GoogleApps.MA.UnitTests/UserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Add()
{
CSEntryChange cs = CSEntryChange.Create();
cs.ObjectModificationType = ObjectModificationType.Add;
cs.DN = $"something@{UnitTestControl.TestParameters.Domain}";
cs.DN = $"something{Guid.NewGuid()}@{UnitTestControl.TestParameters.Domain}";
cs.ObjectType = SchemaConstants.User;

cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("orgUnitPath", "/"));
Expand Down Expand Up @@ -63,6 +63,24 @@ public void Add()
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("phones_work", "phwork"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("phones_home", "phhome"));

cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("keywords_mission", "keyword1"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("keywords_mykeywords", "keyword2"));

cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("locations_desk_area", "area1"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("locations_desk_buildingId", "building-id1"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("locations_desk_deskCode", "desk-code1"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("locations_desk_floorName", "floor-name1"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("locations_desk_floorSection", "floor-section1"));

cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("locations_home_area", "area2"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("locations_home_buildingId", "building-id2"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("locations_home_deskCode", "desk-code2"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("locations_home_floorName", "floor-name2"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("locations_home_floorSection", "floor-section2"));

cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("gender_type", "non-binary"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("gender_addressMeAs", "they/them/theirs"));

cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("ims_work_address", "[email protected]"));
cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("ims_work_protocol", "proto"));

Expand Down Expand Up @@ -94,7 +112,7 @@ public void Add()
Assert.AreEqual("gn", e.Name.GivenName);
Assert.AreEqual("sn", e.Name.FamilyName);

Assert.AreEqual(true, e.IsAdmin);
// Assert.AreEqual(true, e.IsAdmin);

Assert.AreEqual(2, e.ExternalIds.Count);
Assert.AreEqual("eidwork", e.ExternalIds[0].Value);
Expand All @@ -114,6 +132,26 @@ public void Add()
Assert.AreEqual("phwork", e.Phones[0].Value);
Assert.AreEqual("phhome", e.Phones[1].Value);

Assert.AreEqual(2, e.Keywords.Count);
Assert.AreEqual("keyword1", e.Keywords[0].Value);
Assert.AreEqual("keyword2", e.Keywords[1].Value);

Assert.AreEqual(2, e.Locations.Count);
Assert.AreEqual("area1", e.Locations[0].Area);
Assert.AreEqual("building-id1", e.Locations[0].BuildingId);
Assert.AreEqual("desk-code1", e.Locations[0].DeskCode);
Assert.AreEqual("floor-name1", e.Locations[0].FloorName);
Assert.AreEqual("floor-section1", e.Locations[0].FloorSection);

Assert.AreEqual("area2", e.Locations[1].Area);
Assert.AreEqual("building-id2", e.Locations[1].BuildingId);
Assert.AreEqual("desk-code2", e.Locations[1].DeskCode);
Assert.AreEqual("floor-name2", e.Locations[1].FloorName);
Assert.AreEqual("floor-section2", e.Locations[1].FloorSection);

Assert.AreEqual("non-binary", e.Gender.GenderValue);
Assert.AreEqual("they/them/theirs", e.Gender.AddressMeAs);

Assert.AreEqual(1, e.Ims.Count);
Assert.AreEqual("[email protected]", e.Ims[0].IMAddress);
Assert.AreEqual("proto", e.Ims[0].Protocol);
Expand Down Expand Up @@ -290,7 +328,7 @@ public void Update()
cs.AnchorAttributes.Add(AnchorAttribute.Create("id", id));

cs.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("orgUnitPath", "/Unit testing"));

try
{
CSEntryChangeResult result =
Expand All @@ -306,7 +344,7 @@ public void Update()
e = UnitTestControl.TestParameters.UsersService.Get(id);
Assert.AreEqual(cs.DN, e.PrimaryEmail);
Assert.AreEqual("/Unit testing", e.OrgUnitPath);

}
finally
{
Expand Down Expand Up @@ -523,7 +561,7 @@ public void RemoveAliases()

UnitTestControl.TestParameters.UsersService.AddAlias(id, alias1);
UnitTestControl.TestParameters.UsersService.AddAlias(id, alias2);

Thread.Sleep(UnitTestControl.PostGoogleOperationSleepInterval);

CSEntryChange cs = CSEntryChange.Create();
Expand Down Expand Up @@ -876,7 +914,7 @@ public void TakeAdmin()
try
{
UnitTestControl.TestParameters.UsersService.MakeAdmin(true, e.Id);

Thread.Sleep(UnitTestControl.PostGoogleOperationSleepInterval);

CSEntryChange cs = CSEntryChange.Create();
Expand Down
2 changes: 1 addition & 1 deletion src/Lithnet.GoogleApps.MA.UnitTests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<package id="Google.GData.Client" version="2.2.0.0" targetFramework="net452" />
<package id="Google.GData.Contacts" version="2.2.0.0" targetFramework="net452" />
<package id="Google.GData.Extensions" version="2.2.0.0" targetFramework="net452" />
<package id="Lithnet.GoogleApps" version="1.0.7771.31436" targetFramework="net452" />
<package id="Lithnet.GoogleApps" version="1.0.7845.21613" targetFramework="net472" />
<package id="Lithnet.Licensing.Core" version="1.0.7772.24409" targetFramework="net472" />
<package id="Lithnet.Logging" version="1.0.5774.20685" targetFramework="net452" />
<package id="Lithnet.MetadirectoryServices" version="1.0.7578.14947" targetFramework="net452" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ internal interface IManagementAgentParameters

IEnumerable<string> PhonesAttributeFixedTypes { get; }

IEnumerable<string> LocationsAttributeFixedTypes { get; }

IEnumerable<string> KeywordsAttributeFixedTypes { get; }

IEnumerable<string> OrganizationsAttributeFixedTypes { get; }

IEnumerable<string> EmailsAttributeFixedTypes { get; }
Expand Down
11 changes: 7 additions & 4 deletions src/Lithnet.GoogleApps.MA/Lithnet.GoogleApps.MA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@
<HintPath>..\packages\Google.GData.Extensions.2.2.0.0\lib\Google.GData.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Lithnet.GoogleApps, Version=1.0.7771.31436, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lithnet.GoogleApps.1.0.7771.31436\lib\net452\Lithnet.GoogleApps.dll</HintPath>
<Reference Include="Lithnet.GoogleApps, Version=1.0.7845.21613, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lithnet.GoogleApps.1.0.7845.21613\lib\net452\Lithnet.GoogleApps.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Lithnet.Licensing.Core, Version=1.0.7772.24409, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lithnet.Licensing.Core.1.0.7772.24409\lib\netstandard2.0\Lithnet.Licensing.Core.dll</HintPath>
Expand Down Expand Up @@ -310,8 +311,10 @@
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>del $(ProjectDir)$(ProjectName).PackagedMA.xml /f
"C:\Program Files\Microsoft Forefront Identity Manager\2010\Synchronization Service\Bin\mapackager.exe" /e:$(ProjectDir)ExportedMA.xml /c:$(ProjectDir)MAPackageInformation.xml /o:$(ProjectDir)$(ProjectName).PackagedMA.xml</PreBuildEvent>
<PreBuildEvent>
del $(ProjectDir)$(ProjectName).PackagedMA.xml /f
"C:\Program Files\Microsoft Forefront Identity Manager\2010\Synchronization Service\Bin\mapackager.exe" /e:$(ProjectDir)ExportedMA.xml /c:$(ProjectDir)MAPackageInformation.xml /o:$(ProjectDir)$(ProjectName).PackagedMA.xml
</PreBuildEvent>
<PostBuildEvent>call %25BuildToolsPath%25\sign-and-save-symbols.bat $(TargetPath) $(TargetDir) $(ProjectName)</PostBuildEvent>
</PropertyGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
56 changes: 56 additions & 0 deletions src/Lithnet.GoogleApps.MA/ManagementAgentParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,56 @@ public override string KeyFilePassword
}
}

public IEnumerable<string> LocationsAttributeFixedTypes
{
get
{
if (this.configParameters.Contains(ManagementAgentParametersBase.LocationsFixedTypeFormatParameter))
{
string value = this.configParameters[ManagementAgentParametersBase.LocationsFixedTypeFormatParameter].Value;

if (string.IsNullOrWhiteSpace(value))
{
yield break;
}

foreach (string name in value.Split('\n'))
{
yield return name;
}
}
else
{
yield break;
}
}
}

public IEnumerable<string> KeywordsAttributeFixedTypes
{
get
{
if (this.configParameters.Contains(ManagementAgentParametersBase.KeywordsFixedTypeFormatParameter))
{
string value = this.configParameters[ManagementAgentParametersBase.KeywordsFixedTypeFormatParameter].Value;

if (string.IsNullOrWhiteSpace(value))
{
yield break;
}

foreach (string name in value.Split('\n'))
{
yield return name;
}
}
else
{
yield break;
}
}
}

public static IList<ConfigParameterDefinition> GetParameters(KeyedCollection<string, ConfigParameter> configParameters, ConfigParameterPage page)
{
List<ConfigParameterDefinition> parameters = new List<ConfigParameterDefinition>();
Expand Down Expand Up @@ -775,6 +825,12 @@ public static IList<ConfigParameterDefinition> GetParameters(KeyedCollection<str
parameters.Add(ConfigParameterDefinition.CreateTextParameter(ManagementAgentParametersBase.WebsitesFixedTypeFormatParameter, null));
parameters.Add(ConfigParameterDefinition.CreateDividerParameter());

parameters.Add(ConfigParameterDefinition.CreateTextParameter(ManagementAgentParametersBase.LocationsFixedTypeFormatParameter, null));
parameters.Add(ConfigParameterDefinition.CreateDividerParameter());

parameters.Add(ConfigParameterDefinition.CreateTextParameter(ManagementAgentParametersBase.KeywordsFixedTypeFormatParameter, null));
parameters.Add(ConfigParameterDefinition.CreateDividerParameter());

parameters.Add(ConfigParameterDefinition.CreateDividerParameter());
parameters.Add(ConfigParameterDefinition.CreateDropDownParameter(ManagementAgentParametersBase.CalendarBuildingAttributeTypeParameter, new string[] { "String", "Reference" }, false, "String"));
parameters.Add(ConfigParameterDefinition.CreateDropDownParameter(ManagementAgentParametersBase.CalendarFeatureAttributeTypeParameter, new string[] { "String", "Reference" }, false, "String"));
Expand Down
4 changes: 4 additions & 0 deletions src/Lithnet.GoogleApps.MA/ManagementAgentParametersBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ internal abstract class ManagementAgentParametersBase

protected const string AddressesFixedTypeFormatParameter = "Addresses fixed types";

protected const string LocationsFixedTypeFormatParameter = "Locations fixed types";

protected const string KeywordsFixedTypeFormatParameter = "Keywords fixed types";

protected const string EmailsFixedTypeFormatParameter = "Email fixed types";

protected const string CustomUserObjectClassesParameter = "Custom user object classes";
Expand Down
Loading

0 comments on commit 24d49d1

Please sign in to comment.