internal virtual GetAccessPointResponse GetAccessPoint(GetAccessPointRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = GetAccessPointRequestMarshaller.Instance; options.ResponseUnmarshaller = GetAccessPointResponseUnmarshaller.Instance; return(Invoke <GetAccessPointResponse>(request, options)); }
/// <summary> /// Returns configuration information about the specified access point. /// </summary> /// <param name="request">Container for the necessary parameters to execute the GetAccessPoint service method.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>The response from the GetAccessPoint service method, as returned by S3Control.</returns> public virtual Task <GetAccessPointResponse> GetAccessPointAsync(GetAccessPointRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = GetAccessPointRequestMarshaller.Instance; options.ResponseUnmarshaller = GetAccessPointResponseUnmarshaller.Instance; return(InvokeAsync <GetAccessPointResponse>(request, options, cancellationToken)); }
public void ThrowExceptionGetAccessPointCustomEndpointAndOutpostsDualstackNotSupported() { var request = new GetAccessPointRequest { Name = "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint" }; var config = CreateConfig("https://beta.example.com", Flags.Dualstack); S3ControlArnTestUtils.RunMockRequest(request, GetAccessPointRequestMarshaller.Instance, config); }
public void TestNonArnOutpostRequestHasIdFalse() { var request = new GetAccessPointRequest { Name = "test", }; string outpostId = null; Assert.IsFalse(S3ArnUtils.DoesRequestHaveOutpostId(request, out outpostId)); Assert.AreEqual(null, outpostId); }
public void VpceEndpointTests_GetAccessPoint(string accessPointName, string serviceUrl, Flags flags, string expectedUri, string expectedRegion, string expectedService) { var request = new GetAccessPointRequest { AccountId = "123456789012", Name = accessPointName }; RunTestRequest(request, GetAccessPointRequestMarshaller.Instance, Arn.IsArn(accessPointName), serviceUrl, flags, expectedUri, expectedRegion, expectedService); }
public void OutpostsAccessPointInputUSWest2UseArnRegionFalse() { var outpostsAccessPointArn = "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"; var s3ControlConfig = new AmazonS3ControlConfig { RegionEndpoint = RegionEndpoint.USWest2 }; var getAccessPointRequest = new GetAccessPointRequest { Name = outpostsAccessPointArn }; var marshalledRequest = S3ControlArnTestUtils.RunMockRequest(getAccessPointRequest, GetAccessPointRequestMarshaller.Instance, s3ControlConfig); Assert.AreEqual(new Uri("https://s3-outposts.us-west-2.amazonaws.com"), marshalledRequest.Endpoint); Assert.AreEqual("op-01234567890123456", marshalledRequest.Headers[HeaderKeys.XAmzOutpostId]); Assert.AreEqual("123456789012", marshalledRequest.Headers[HeaderKeys.XAmzAccountId]); }
public void ArnIdNotSetFieldIdSet() { var accessPoint = "myAccessPoint"; var s3ControlConfig = new AmazonS3ControlConfig { UseArnRegion = true, RegionEndpoint = RegionEndpoint.USWest2 }; var getAccessPointRequest = new GetAccessPointRequest { Name = accessPoint, AccountId = "123456789012" }; var marshalledRequest = S3ControlArnTestUtils.RunMockRequest(getAccessPointRequest, GetAccessPointRequestMarshaller.Instance, s3ControlConfig); Assert.AreEqual("123456789012", marshalledRequest.Headers["x-amz-account-id"]); }
public void OutpostsAccessPointInputUSWest2UseArnRegionTrueInvalidArnException(string outpostsAccessPointArn) { var s3ControlConfig = new AmazonS3ControlConfig { RegionEndpoint = RegionEndpoint.USWest2, UseArnRegion = true }; var getAccessPointRequest = new GetAccessPointRequest { Name = outpostsAccessPointArn }; var exception = Assert.ThrowsException <AmazonClientException>(() => { S3ControlArnTestUtils.RunMockRequest(getAccessPointRequest, GetAccessPointRequestMarshaller.Instance, s3ControlConfig); }); Assert.AreEqual("Invalid ARN, outpost resource format is incorrect", exception.Message); }
public void OutpostsAccessPointInputUSGovEast1UseArnRegionTrueSystemFips() { var outpostsAccessPointArn = "arn:aws-us-gov:s3-outposts:us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"; var s3ControlConfig = new AmazonS3ControlConfig { RegionEndpoint = RegionEndpoint.GetBySystemName("fips-us-gov-east-1"), UseArnRegion = true }; var getAccessPointRequest = new GetAccessPointRequest { Name = outpostsAccessPointArn }; var marshalledRequest = S3ControlArnTestUtils.RunMockRequest(getAccessPointRequest, GetAccessPointRequestMarshaller.Instance, s3ControlConfig); Assert.AreEqual(new Uri("https://s3-outposts.us-gov-east-1.amazonaws.com"), marshalledRequest.Endpoint); Assert.AreEqual("op-01234567890123456", marshalledRequest.Headers[HeaderKeys.XAmzOutpostId]); Assert.AreEqual("123456789012", marshalledRequest.Headers[HeaderKeys.XAmzAccountId]); }
public void OutpostsAccessPointInputUSEast1UseArnRegionFalseCrossRegionError() { var outpostsAccessPointArn = "arn:aws:s3-outposts:us-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"; var s3ControlConfig = new AmazonS3ControlConfig { RegionEndpoint = RegionEndpoint.USWest2, UseArnRegion = false }; var getAccessPointRequest = new GetAccessPointRequest { Name = outpostsAccessPointArn }; var exception = Assert.ThrowsException <AmazonClientException>(() => { S3ControlArnTestUtils.RunMockRequest(getAccessPointRequest, GetAccessPointRequestMarshaller.Instance, s3ControlConfig); }); Assert.AreEqual("Invalid configuration, cross region Outpost Access Point ARN", exception.Message); }
public void OutpostsAccessPointInputUSGovEast1UseArnRegionTrueFipsException() { var outpostsAccessPointArn = "arn:aws-us-gov:s3-outposts:fips-us-gov-east-1:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"; var s3ControlConfig = new AmazonS3ControlConfig { RegionEndpoint = RegionEndpoint.GetBySystemName("fips-us-gov-east-1"), UseArnRegion = true }; var getAccessPointRequest = new GetAccessPointRequest { Name = outpostsAccessPointArn }; var exception = Assert.ThrowsException <AmazonClientException>(() => { S3ControlArnTestUtils.RunMockRequest(getAccessPointRequest, GetAccessPointRequestMarshaller.Instance, s3ControlConfig); }); Assert.AreEqual("Invalid configuration Outpost Access Points do not support Fips- regions", exception.Message); }
public void ArnIdNotSetFieldIdNotSetInvalidArnException() { var accessPointName = "arn:aws:s3-outposts:us-west-2::outpost:op-01234567890123456:bucket:mybucket"; var s3ControlConfig = new AmazonS3ControlConfig { UseArnRegion = true, RegionEndpoint = RegionEndpoint.USWest2 }; var getAccessPointRequest = new GetAccessPointRequest { Name = accessPointName }; var exception = Assert.ThrowsException <AmazonClientException>(() => { S3ControlArnTestUtils.RunMockRequest(getAccessPointRequest, GetAccessPointRequestMarshaller.Instance, s3ControlConfig); }); Assert.AreEqual("Invalid ARN, Account ID not set", exception.Message); }
public void OutpostsAccessPointInputUSWest2UseArnRegionTrueDualstackException() { var outpostsAccessPointArn = "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"; var s3ControlConfig = new AmazonS3ControlConfig { RegionEndpoint = RegionEndpoint.USWest2, UseDualstackEndpoint = true, UseArnRegion = true }; var getAccessPointRequest = new GetAccessPointRequest { Name = outpostsAccessPointArn }; var exception = Assert.ThrowsException <AmazonClientException>(() => { S3ControlArnTestUtils.RunMockRequest(getAccessPointRequest, GetAccessPointRequestMarshaller.Instance, s3ControlConfig); }); Assert.AreEqual("Invalid configuration Outpost Access Points do not support dualstack", exception.Message); }
public void ArnIdSetFieldIdSetMismatchException() { var accessPointName = "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:bucket:mybucket"; var s3ControlConfig = new AmazonS3ControlConfig { UseArnRegion = true, RegionEndpoint = RegionEndpoint.USWest2 }; var getAccessPointRequest = new GetAccessPointRequest { AccountId = "923456789012", Name = accessPointName }; var exception = Assert.ThrowsException <AmazonClientException>(() => { S3ControlArnTestUtils.RunMockRequest(getAccessPointRequest, GetAccessPointRequestMarshaller.Instance, s3ControlConfig); }); Assert.AreEqual("Account ID mismatch, the Account ID cannot be specified in an ARN and in the accountId field", exception.Message); }
public void TestS3OutpostsSignerGetAccessPoint() { var signer = new S3Signer(); var outpostsArn = "arn:aws:s3-outposts:us-west-2:123456789012:outpost:op-01234567890123456:accesspoint:myaccesspoint"; var getAccessPointRequest = new GetAccessPointRequest { Name = outpostsArn }; var config = new AmazonS3ControlConfig { UseArnRegion = true, RegionEndpoint = RegionEndpoint.USWest2 }; var originalAuthService = config.AuthenticationServiceName; var iRequest = S3ControlArnTestUtils.RunMockRequest(getAccessPointRequest, GetAccessPointRequestMarshaller.Instance, config); signer.Sign(iRequest, config, new RequestMetrics(), new ImmutableCredentials("ACCESS", "SECRET", "")); Assert.IsTrue(iRequest.Headers.ContainsKey(HeaderKeys.AuthorizationHeader)); Assert.IsTrue((iRequest.Headers["Authorization"]).Contains("s3-outposts")); Assert.IsTrue(config.AuthenticationServiceName == originalAuthService); }
public void S3OutpostsAccessPointARNTests(string accesspointNameInput, string clientRegion, string additionalFlags, string useArnRegion, string expectedEndpoint, string expectedHeaders, string expectedSignedBy) { Console.WriteLine(string.Join(" | ", accesspointNameInput, clientRegion, additionalFlags, useArnRegion, expectedEndpoint, expectedHeaders, expectedSignedBy)); Console.WriteLine(); // ARRANGE // expectedEndpoint can be overloaded with the expected error message var expectSuccess = expectedEndpoint.Contains("amazonaws.com"); // outputs to assert against: IRequest s3Request = null; Exception exception = null; var request = new GetAccessPointRequest { Name = accesspointNameInput, AccountId = "123456789012" }; var config = new AmazonS3ControlConfig { RegionEndpoint = clientRegion == "" ? null : RegionEndpoint.GetBySystemName(clientRegion), UseArnRegion = useArnRegion == "" ? false : bool.Parse(useArnRegion) }; if (additionalFlags.Contains("dualstack")) { config.UseDualstackEndpoint = true; } if (additionalFlags.Contains("fips")) { config.UseFIPSEndpoint = true; } if (additionalFlags.Contains("accelerate") && !expectSuccess) { // S3 Control Config does not allow setting accelerate, so it will not generate the expected error return; } // ACT try { s3Request = S3ControlArnTestUtils.RunMockRequest(request, GetAccessPointRequestMarshaller.Instance, config); Console.WriteLine(s3Request.Endpoint.ToString()); Console.WriteLine(); } catch (Exception e) { exception = e; } // ASSERT if (expectSuccess) { Assert.IsNull(exception, exception?.Message); Assert.IsNotNull(s3Request); AssertExtensions.UrlSuffixMatches(expectedEndpoint, s3Request.Endpoint); AssertExtensions.ContainsHeaders(SpecMarkdownTestDataHelper.ParseExpectedHeaders(expectedHeaders), s3Request.Headers); } else { Assert.IsNull(s3Request); Assert.IsNotNull(exception); // reminder, expectedEndpoint also contains expected error message. AssertExtensions.AssertAreSameWithEmbellishments(expectedEndpoint, exception.Message); } }