Example #1
0
 public Team Expand(TeamProject teamProject)
 {
     return(new Team
     {
         Name = this.Name.Expand(teamProject),
         Members = this.Members.Select(m => m.Expand(teamProject)).ToArray()
     });
 }
Example #2
0
 public Namespace Expand(TeamProject teamProject)
 {
     return(new Namespace
     {
         Allow = this.Allow.Select(a => a.Expand(teamProject)).ToArray(),
         Deny = this.Deny.Select(d => d.Expand(teamProject)).ToArray(),
         Name = this.Name.Expand(teamProject)
     });
 }
Example #3
0
        public override Pattern Expand(TeamProject teamProject)
        {
            var result = new SecurityPattern(this.graphService);

            this.Expand(result, teamProject);
            result.ApplicationGroups = this.ApplicationGroups.Select(ag => ag.Expand(teamProject)).ToList();

            return(result);
        }
Example #4
0
 public ApplicationGroup Expand(TeamProject teamProject)
 {
     return(new ApplicationGroup
     {
         Name = this.Name.Expand(teamProject),
         Namespaces = this.Namespaces.Select(n => n.Expand(teamProject)).ToList(),
         Members = this.Members.Select(m => m.Expand(teamProject)).ToArray()
     });
 }
Example #5
0
        public async override Task <IEnumerable <Deviation> > CollectDeviations(TeamProject teamProject)
        {
            var results = (await base.CollectDeviations(teamProject).ConfigureAwait(false)).ToList();
            var currentApplicationGroups = await this.graphService.GetApplicationGroups(teamProject).ConfigureAwait(false);

            // Check if the application group exists
            var missingApplicationGroupDeviations = this.ApplicationGroups
                                                    .Where(ag => currentApplicationGroups.All(cag => !cag.Name.Equals(ag.Name, StringComparison.OrdinalIgnoreCase)))
                                                    .Select(ag => new ApplicationGroupDeviation {
                ApplicationGroup = ag, TeamProject = teamProject, Type = DeviationType.Missing
            })
                                                    .ToList();

            // Check for obsolete application groups.
            var obsoleteApplicationGroupDeviations = currentApplicationGroups
                                                     .Where(cag => !cag.IsSpecial)
                                                     .Where(cag => this.ApplicationGroups.All(ag => !ag.Name.Equals(cag.Name, StringComparison.OrdinalIgnoreCase)))
                                                     .Select(ag => new ApplicationGroupDeviation {
                ApplicationGroup = ag, TeamProject = teamProject, Type = DeviationType.Obsolete
            })
                                                     .ToList();

            foreach (var applicationGroup in this.ApplicationGroups)
            {
                var currentMembers = currentApplicationGroups.Any(ag => ag.Name.Equals(applicationGroup.Name, StringComparison.OrdinalIgnoreCase))
                                     ? (await this.graphService.GetMembers(teamProject, applicationGroup).ConfigureAwait(false))
                                     : new List <string>();

                // Check if the application group contains the correct members
                var missingApplicationGroupMemberDeviations = applicationGroup.Members
                                                              .Where(member => currentMembers.All(cm => !cm.Equals(member, StringComparison.OrdinalIgnoreCase)))
                                                              .Select(m => new ApplicationGroupMemberDeviation {
                    ApplicationGroup = applicationGroup, Member = m, TeamProject = teamProject, Type = DeviationType.Missing
                })
                                                              .ToList();

                // Check for obsolete members
                var obsoleteApplictionGroupMemberDeviations = currentMembers
                                                              .Where(cm => applicationGroup.Members.All(m => !m.Equals(cm, StringComparison.OrdinalIgnoreCase)))
                                                              .Select(cm => new ApplicationGroupMemberDeviation {
                    ApplicationGroup = applicationGroup, Member = cm, TeamProject = teamProject, Type = DeviationType.Obsolete
                })
                                                              .ToList();

                results.AddRange(missingApplicationGroupMemberDeviations);
                results.AddRange(obsoleteApplictionGroupMemberDeviations);

                // TODO: Iterate through the namespaces and check the permissions
            }

            results.AddRange(missingApplicationGroupDeviations);
            results.AddRange(obsoleteApplicationGroupDeviations);

            return(results);
        }
        /// <summary>
        /// Expands <see cref="TeamProject"/> property values in a string.
        /// </summary>
        /// <param name="target">The <see cref="string"/> where to expand property values in.</param>
        /// <param name="teamProject">The <see cref="TeamProject"/> instance which property values should be added to the <paramref name="target"/>.</param>
        /// <returns>The <see cref="string"/> which contains expanded property values.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="target"/> or <paramref name="teamProject"/> is null.</exception>
        public static string Expand(this string target, TeamProject teamProject)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            if (teamProject == null)
            {
                throw new ArgumentNullException(nameof(teamProject));
            }

            return(Regex.Replace(target, @"{(?<exp>[^}]+)}", match =>
            {
                var p = Expression.Parameter(typeof(TeamProject), "teamProject");
                var e = DynamicExpressionParser.ParseLambda(new[] { p }, null, match.Groups["exp"].Value);

                return (e.Compile().DynamicInvoke(teamProject) ?? string.Empty).ToString();
            }));
        }
Example #7
0
 public virtual Pattern Expand(Pattern pattern, TeamProject teamProject)
 {
     pattern.Name = this.Name.Expand(teamProject);
     return(pattern);
 }
Example #8
0
 public virtual Pattern Expand(TeamProject teamProject)
 {
     return(this.Expand(new Pattern(), teamProject));
 }
Example #9
0
 public async virtual Task <IEnumerable <Deviation> > CollectDeviations(TeamProject teamProject)
 {
     return(await Task.FromResult(new List <Deviation>()).ConfigureAwait(false));
 }