Extend AssemblyAssertions with methods to check on assemblies being signed or not
See original GitHub issueBackground and motivation
To ensure that the public key of an signed assembly does not accidentally changes, having an assertion .HavePublicKey(string)
can help. For completeness/symmetry reasons adding .BeUnsigned()
might be beneficial too.
API Proposal
public class AssemblyAssertions : ReferenceTypeAssertions<Assembly, AssemblyAssertions>
{
public AndConstraint<AssemblyAssertions> NotHavePublicKey(string because = "", params object[] becauseArgs);
public AndConstraint<AssemblyAssertions> HavePublicKey(string publicKey, string because = "", params object[] becauseArgs);
}
API Usage
var signed = typeof(AssemblyA.ClassA).Assembly;
signed.Should().HavePublicKey("sdfds");
var unsigned = typeof(AssemblyB.ClassB).Assembly;
unsigned.Should().NotHavePublicKey();
Alternative Designs
No response
Risks
No response
Issue Analytics
- State:
- Created 4 months ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
how to unit testing delay-sign assemblies using nunit
If we test those assemblies using nunit (GUI version), the test won't work (all tests are failed) because of delay-signed. But if those ......
Read more >Asserting Permissions in Custom Assemblies - SQL
Learn how to assert permissions so you can implement a custom assembly that makes secured calls to protected resources within your security ...
Read more >C# static code analysis: Assemblies should be marked with ...
This rule raises an issue when an assembly contains a ResX -based resource but does not have the System.Resources.NeutralResourcesLanguageAttribute applied to ...
Read more >Understanding How Assert Effects Security
Assert is a security action that is evaluated at run time. Code Access Permission classes and Permission Sets support a method called Assert...
Read more >Using Assertions to Enhance the Correctness of Kmelia ...
The main idea is, first to con- sider a part of the Kmelia specification involved in the property to be verified (a service,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see the reasoning behind
.NotHavePublicKey
vs.HavePublicKey
. That being said, from a test a specification perspective,someAssembly.Should().BeUnsigned()
tells the story better thansomeAssembly.Should().NotHavePublicKey()
. The latter hints to something likesomeAssembly.Should().NotHavePublicKey("InvalidKey")
.For me
.HavePublicKey(key)
is short for.BeSignedWithPublicKey(key)
, or.BeSignedWith(key)
, hence my original proposal.I’ve updated the proposal with the approved API.