public object Resolve(object source, Dictionary <string, IResolver> resolvers = null, bool recursive = false) { TeamSecurity result = null; var security = source.GetPublicInstancePropertyValue("Security"); if (null != security) { result = new TeamSecurity(); // Process settings var clearExistingOwnersValue = (security?.GetPublicInstancePropertyValue("Owners")?.GetPublicInstancePropertyValue("ClearExistingItems")); result.ClearExistingOwners = clearExistingOwnersValue != null ? (Boolean)clearExistingOwnersValue : false; var clearExistingMembersValue = (security?.GetPublicInstancePropertyValue("Members")?.GetPublicInstancePropertyValue("ClearExistingItems")); result.ClearExistingMembers = clearExistingMembersValue != null ? (Boolean)clearExistingMembersValue : false; // Process users (owners and members) var usersResolver = new CollectionFromSchemaToModelTypeResolver(typeof(TeamSecurityUser)); var owners = security.GetPublicInstancePropertyValue("Owners"); if (null != owners) { result.Owners.AddRange( usersResolver.Resolve(owners.GetPublicInstancePropertyValue("User")) as IEnumerable <TeamSecurityUser>); } var members = security.GetPublicInstancePropertyValue("Members"); if (null != members) { result.Members.AddRange( usersResolver.Resolve(members.GetPublicInstancePropertyValue("User")) as IEnumerable <TeamSecurityUser>); } var allowToAddGuests = security.GetPublicInstancePropertyValue("AllowToAddGuests"); result.AllowToAddGuests = allowToAddGuests != null?bool.Parse(allowToAddGuests.ToString()) : false; } return(result); }
public void Initialize() { if (!TestCommon.AppOnlyTesting()) { const string teamTemplateName = "Sample Engineering Team"; _teamNames.Add(teamTemplateName); _jsonTemplate = "{ \"[email protected]\": \"https://graph.microsoft.com/beta/teamsTemplates(\'standard\')\", \"visibility\": \"Private\", \"displayName\": \"" + teamTemplateName + "\", \"description\": \"This is a sample engineering team, used to showcase the range of properties supported by this API\", \"channels\": [ { \"displayName\": \"Announcements 📢\", \"isFavoriteByDefault\": true, \"description\": \"This is a sample announcements channel that is favorited by default. Use this channel to make important team, product, and service announcements.\" }, { \"displayName\": \"Training 🏋️\", \"isFavoriteByDefault\": true, \"description\": \"This is a sample training channel, that is favorited by default, and contains an example of pinned website and YouTube tabs.\", \"tabs\": [ { \"[email protected]\": \"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'com.microsoft.teamspace.tab.web\')\", \"name\": \"A Pinned Website\", \"configuration\": { \"contentUrl\": \"https://docs.microsoft.com/en-us/microsoftteams/microsoft-teams\" } }, { \"[email protected]\": \"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'com.microsoft.teamspace.tab.youtube\')\", \"name\": \"A Pinned YouTube Video\", \"configuration\": { \"contentUrl\": \"https://tabs.teams.microsoft.com/Youtube/Home/YoutubeTab?videoId=X8krAMdGvCQ\", \"websiteUrl\": \"https://www.youtube.com/watch?v=X8krAMdGvCQ\" } } ] }, { \"displayName\": \"Planning 📅 \", \"description\": \"This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.\", \"isFavoriteByDefault\": false }, { \"displayName\": \"Issues and Feedback 🐞\", \"description\": \"This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.\" } ], \"memberSettings\": { \"allowCreateUpdateChannels\": true, \"allowDeleteChannels\": true, \"allowAddRemoveApps\": true, \"allowCreateUpdateRemoveTabs\": true, \"allowCreateUpdateRemoveConnectors\": true }, \"guestSettings\": { \"allowCreateUpdateChannels\": false, \"allowDeleteChannels\": false }, \"funSettings\": { \"allowGiphy\": true, \"giphyContentRating\": \"Moderate\", \"allowStickersAndMemes\": true, \"allowCustomMemes\": true }, \"messagingSettings\": { \"allowUserEditMessages\": true, \"allowUserDeleteMessages\": true, \"allowOwnerDeleteMessages\": true, \"allowTeamMentions\": true, \"allowChannelMentions\": true }, \"installedApps\": [ { \"[email protected]\": \"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'com.microsoft.teamspace.tab.vsts\')\" }, { \"[email protected]\": \"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps(\'1542629c-01b3-4a6d-8f76-1938b779e48d\')\" } ] }"; const string teamName = @"Unallowed &_,.;:/\""!@$%^*[]+=&'|<>{}-()?#¤`´~¨ Ääkköset"; _teamNames.Add(teamName); var security = new TeamSecurity { AllowToAddGuests = false, Owners = { new TeamSecurityUser { UserPrincipalName = ConfigurationManager.AppSettings["SPOUserName"] } } }; var funSettings = new TeamFunSettings { AllowCustomMemes = true, AllowGiphy = true, AllowStickersAndMemes = true, GiphyContentRating = TeamGiphyContentRating.Moderate }; var guestSettings = new TeamGuestSettings { AllowCreateUpdateChannels = false, AllowDeleteChannels = false }; var memberSettings = new TeamMemberSettings { AllowDeleteChannels = false, AllowAddRemoveApps = true, AllowCreateUpdateChannels = true, AllowCreateUpdateRemoveConnectors = false, AllowCreateUpdateRemoveTabs = true }; var messagingSettings = new TeamMessagingSettings { AllowChannelMentions = true, AllowOwnerDeleteMessages = true, AllowTeamMentions = false, AllowUserDeleteMessages = true, AllowUserEditMessages = true }; var channel = new TeamChannel { DisplayName = "Another channel", Description = "Another channel description!", IsFavoriteByDefault = true }; var tab = new TeamTab { DisplayName = "OneNote Tab", TeamsAppId = "0d820ecd-def2-4297-adad-78056cde7c78"/*, * Configuration = new TeamTabConfiguration * { * ContentUrl = "https://todo-improve-this-test-when-tab-resource-provisioning-has-been-implemented" * }*/ }; channel.Tabs.Add(tab); var message = new TeamChannelMessage { Message = "Welcome to this awesome new channel!" }; channel.Messages.Add(message); _team = new Team { DisplayName = teamName, Description = "Testing creating mailNickname from a display name that has unallowed and accented characters", Visibility = TeamVisibility.Public, Security = security, FunSettings = funSettings, GuestSettings = guestSettings, MemberSettings = memberSettings, MessagingSettings = messagingSettings, Channels = { channel } }; } }