public void TestParseOnlyClosingBracket() { string textToParse = "test.property}_update"; // when, then: Assert.Throws <InvalidOperationException>(() => AttributeExpressionParser.Parse(textToParse)); }
public void TestParseOnlyOpeningBracket() { string textToParse = "user_{test.property1_read"; // when:then: Assert.Throws <InvalidOperationException>(() => AttributeExpressionParser.Parse(textToParse)); }
public void TestStandardText() { string textToParse = "test_{12345.test}_update"; // when: string actualExpression = AttributeExpressionParser.Parse(textToParse); // then: actualExpression.ShouldBeEquivalentTo("12345.test"); }
public void TestOnlyExpressionTest() { string textToParse = "{test.property1}"; // when: string actualExpression = AttributeExpressionParser.Parse(textToParse); // then: actualExpression.ShouldBeEquivalentTo("test.property1"); }
private SimpleGrantedAuthority GetAuthorityForExpression(string permission) { // Wenn es keinen Nutzer gibt, kann nichts evaluiert werden, also gibt es auch keine Berechtigung. if (_user == null) { return(null); } string expression = AttributeExpressionParser.Parse(permission); object evaluatedExpression = ExpressionEvaluator.GetValue(_user, expression); if (evaluatedExpression == null) { // Es konnte kein Wert bestimmt werden, also gibt es auch keine Berechtigung. return(null); } string first = permission.Split('{').First(); string last = permission.Split('}').Last(); SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(first + evaluatedExpression + last); return(simpleGrantedAuthority); }