public void TestSignerWithAnonymousCredentials() { var pipeline = new RuntimePipeline(new MockHandler()); pipeline.AddHandler(new Signer()); pipeline.AddHandler(new CredentialsRetriever(new AnonymousAWSCredentials())); var context = CreateTestContext(); var signer = new MockSigner(); ((RequestContext)context.RequestContext).Signer = signer; pipeline.InvokeSync(context); Assert.IsTrue(context.RequestContext.IsSigned); Assert.AreEqual(0, signer.SignCount); }
public void TestSignerWithBasicCredentials() { var pipeline = new RuntimePipeline(new MockHandler()); pipeline.AddHandler(new Signer()); pipeline.AddHandler(new CredentialsRetriever(new BasicAWSCredentials("accessKey", "secretKey"))); var context = CreateTestContext(); var signer = new MockSigner(); ((RequestContext)context.RequestContext).Signer = signer; pipeline.InvokeSync(context); Assert.IsTrue(context.RequestContext.IsSigned); Assert.AreEqual(1, signer.SignCount); }
public void TestSignerWithMutableHeader() { var pipeline = new RuntimePipeline(new MockHandler()); pipeline.AddHandler(new Signer()); pipeline.AddHandler(new CredentialsRetriever(new BasicAWSCredentials("accessKey", "secretKey"))); var context = CreateTestContext(); var signer = new AWS4Signer(); ((RequestContext)context.RequestContext).Signer = signer; // inject a mutable header that the signer should strip out context.RequestContext.Request.Headers[HeaderKeys.XAmznTraceIdHeader] = "stuff"; pipeline.InvokeSync(context); // verify that the header is not in the signature var t = context.RequestContext.Request.Headers[HeaderKeys.AuthorizationHeader]; Assert.IsFalse(t.Contains(HeaderKeys.XAmznTraceIdHeader)); Assert.IsTrue(context.RequestContext.Request.Headers.ContainsKey(HeaderKeys.XAmznTraceIdHeader)); }