protected override void ProcessRecordInner(IServiceProvider services)
        {
            List <FluentResponseMessage> messages = new List <FluentResponseMessage>();

            try
            {
                ICreateBankClientProfile  createBankClientProfile = services.GetService <ICreateBankClientProfile>();
                BankClientProfileResponse response = createBankClientProfile
                                                     .CreateAsync(BankClientProfile)
                                                     .GetAwaiter()
                                                     .GetResult();
                BankClientProfileFluentResponse response2 =
                    new BankClientProfileFluentResponse(messages: messages, data: response);
                WriteObject(response2);
            }
            catch (Exception ex)
            {
                WriteError(
                    new ErrorRecord(
                        exception: ex,
                        errorId: "Could not create record",
                        errorCategory: ErrorCategory.InvalidOperation,
                        targetObject: null));
            }
        }
コード例 #2
0
        public async Task Repository_ClientUpserted()
        {
            BankClientProfileContext ctx = CreateOpenBankingRequestBuilder().BankClientProfile();

            string issuerUrl            = "http://aaa.com/";
            string xfapi2               = "xfapi2";
            string softwareStatementId2 = "softwareStatementId2";


            BankClientProfileFluentResponse result1 = await ctx
                                                      .Id("BankClientProfileId")
                                                      .IssuerUrl(new Uri(issuerUrl))
                                                      .XFapiFinancialId("xfapi")
                                                      .SoftwareStatementProfileId("softwareStatement")
                                                      .HttpMtlsOverrides(new HttpMtlsConfigurationOverrides
            {
                TlsCertificateVerification = "aaa",
                TlsRenegotiationSupport    = "bbb"
            })
                                                      .RegistrationClaimsOverrides(new BankClientRegistrationClaimsOverrides())
                                                      .OpenIdRegistrationEndpointUrl(new Uri("http://bbb.com"))
                                                      .RegistrationResponseOverrides(new BankClientRegistrationDataOverrides())
                                                      .UpsertAsync();

            result1.Messages.Should().HaveCount(0);

            BankClientProfileFluentResponse result2 = await ctx
                                                      .IssuerUrl(new Uri(issuerUrl))
                                                      .XFapiFinancialId(xfapi2)
                                                      .SoftwareStatementProfileId(softwareStatementId2)
                                                      .HttpMtlsOverrides(new HttpMtlsConfigurationOverrides
            {
                TlsCertificateVerification = "aaa",
                TlsRenegotiationSupport    = "bbb"
            })
                                                      .RegistrationClaimsOverrides(new BankClientRegistrationClaimsOverrides())
                                                      .OpenIdRegistrationEndpointUrl(new Uri("http://bbb.com"))
                                                      .RegistrationResponseOverrides(new BankClientRegistrationDataOverrides())
                                                      .UpsertAsync();

            result2.Messages.Should().HaveCount(0);


            Connector.Persistence.IDbEntityRepository <Models.Persistent.BankClientProfile> repo = ctx.Context.ClientProfileRepository;

            IQueryable <Models.Persistent.BankClientProfile> instances = await repo.GetAllAsync();

            Models.Persistent.BankClientProfile persistedResult = instances.FirstOrDefault();


            persistedResult.IssuerUrl.Should().Be(issuerUrl);
            persistedResult.XFapiFinancialId.Should().Be(xfapi2);
            persistedResult.SoftwareStatementProfileId.Should().Be(softwareStatementId2);
        }
コード例 #3
0
        public void RunMockPaymentTest()
        {
            IOpenBankingRequestBuilder requestBuilder = _mockData.CreateMockRequestBuilder();

            OpenBankingSoftwareStatementResponse softwareStatementProfileResp = requestBuilder
                                                                                .SoftwareStatementProfile()
                                                                                .Id("0")
                                                                                .SoftwareStatement(
                "header.ewogICJzb2Z0d2FyZV9pZCI6ICJpZCIsCiAgInNvZnR3YXJlX2NsaWVudF9pZCI6ICJjbGllbnRfaWQiLAogICJzb2Z0d2FyZV9jbGllbnRfbmFtZSI6ICJUUFAgQ2xpZW50IiwKICAic29mdHdhcmVfY2xpZW50X2Rlc2NyaXB0aW9uIjogIkNsaWVudCBkZXNjcmlwdGlvbiIsCiAgInNvZnR3YXJlX3ZlcnNpb24iOiAxLAogICJzb2Z0d2FyZV9jbGllbnRfdXJpIjogImh0dHBzOi8vZXhhbXBsZS5jb20iLAogICJzb2Z0d2FyZV9yZWRpcmVjdF91cmlzIjogWwogICAgImh0dHBzOi8vZXhhbXBsZS5jb20iCiAgXSwKICAic29mdHdhcmVfcm9sZXMiOiBbCiAgICAiQUlTUCIsCiAgICAiUElTUCIsCiAgICAiQ0JQSUkiCiAgXSwKICAib3JnX2lkIjogIm9yZ19pZCIsCiAgIm9yZ19uYW1lIjogIk9yZyBOYW1lIiwKICAic29mdHdhcmVfb25fYmVoYWxmX29mX29yZyI6ICJPcmcgTmFtZSIKfQ==.signature")
                                                                                .SigningKeyInfo(
                keyId: "signingkeyid",
                keySecretName: _mockData.GetMockPrivateKey(),
                certificate: _mockData.GetMockCertificate())
                                                                                .TransportKeyInfo(
                keySecretName: _mockData.GetMockPrivateKey(),
                certificate: _mockData.GetMockCertificate())
                                                                                .DefaultFragmentRedirectUrl("http://redirecturl.com")
                                                                                .SubmitAsync().Result;

            softwareStatementProfileResp.Messages.Should().BeEmpty();
            softwareStatementProfileResp.Data.Should().NotBeNull();
            softwareStatementProfileResp.Data.Id.Should().NotBeNullOrWhiteSpace();

            _mockPaymentsServer.SetUpOpenIdMock();
            _mockPaymentsServer.SetupRegistrationMock();

            BankClientProfileFluentResponse bankClientProfileResp = requestBuilder.BankClientProfile()
                                                                    .Id("MyBankClientProfileId")
                                                                    .SoftwareStatementProfileId(softwareStatementProfileResp.Data.Id)
                                                                    .IssuerUrl(new Uri(MockRoutes.Url))
                                                                    .XFapiFinancialId(_mockData.GetFapiHeader())
                                                                    .BankClientRegistrationClaimsOverrides(new BankClientRegistrationClaimsOverrides())
                                                                    .SubmitAsync().Result;

            bankClientProfileResp.Should().NotBeNull();
            bankClientProfileResp.Messages.Should().BeEmpty();
            bankClientProfileResp.Data.Should().NotBeNull();

            PaymentInitiationApiProfileFluentResponse paymentInitiationApiProfileResp = requestBuilder
                                                                                        .PaymentInitiationApiProfile()
                                                                                        .Id("NewPaymentInitiationProfile")
                                                                                        .BankClientProfileId(bankClientProfileResp.Data.Id)
                                                                                        .PaymentInitiationApiInfo(apiVersion: ApiVersion.V3P1P4, baseUrl: MockRoutes.Url)
                                                                                        .SubmitAsync().Result;

            paymentInitiationApiProfileResp.Should().NotBeNull();
            paymentInitiationApiProfileResp.Messages.Should().BeEmpty();
            paymentInitiationApiProfileResp.Data.Should().NotBeNull();

            _mockPaymentsServer.SetupTokenEndpointMock();
            _mockPaymentsServer.SetupPaymentEndpointMock();

            DomesticPaymentConsentFluentResponse consentResp = requestBuilder
                                                               .DomesticPaymentConsent(paymentInitiationApiProfileResp.Data.Id)
                                                               .Merchant(
                merchantCategory: null,
                merchantCustomerId: null,
                paymentContextCode: OBRisk1.PaymentContextCodeEnum.EcommerceGoods)
                                                               .CreditorAccount(
                identification: "BE56456394728288",
                schema: "IBAN",
                name: "ACME DIY",
                secondaryId: "secondary-identif")
                                                               .DeliveryAddress(new OBRisk1DeliveryAddress
            {
                BuildingNumber = "42",
                StreetName     = "Oxford Street",
                TownName       = "London",
                Country        = "UK",
                PostCode       = "SW1 1AA"
            })
                                                               .Amount(currency: "GBP", value: 50)
                                                               .InstructionIdentification("instr-identification")
                                                               .EndToEndIdentification("e2e-identification")
                                                               .Remittance(new OBWriteDomestic2DataInitiationRemittanceInformation
            {
                Unstructured = "Tools",
                Reference    = "Tools"
            })
                                                               .SubmitAsync().Result;

            consentResp.Should().NotBeNull();
            consentResp.Messages.Should().BeEmpty();
            consentResp.Data.Should().NotBeNull();

            // Check redirect matches above.
            // Check scope = "openid payments"
            // Check response type = "code id_token"
            // Check client ID matches above

            // Call mock bank with auth URL and check.... then return at least auth code and state....

            // Call Fluent method to pass auth code and state (set up mock bank token endpoint)
            AuthorisationCallbackDataFluentResponse authCallbackDataResp = requestBuilder.AuthorisationCallbackData()
                                                                           .ResponseMode("fragment")
                                                                           .Response(
                new AuthorisationCallbackPayload(
                    authorisationCode: "TODO: place code from mock bank here",
                    state: "TODO: extract state from consentResp.Data.AuthUrl and place here")
            {
                Nonce = "TODO: extract nonce from consentResp.Data.AuthUrl and place here"
            })
                                                                           .SubmitAsync().Result;

            //authCallbackDataResp.Should().NotBeNull();
            //authCallbackDataResp.Messages.Should().BeEmpty();
            //authCallbackDataResp.Data.Should().NotBeNull();

            // Call Fluent method to make payment (set up mock bank payment endpoint)
            DomesticPaymentFluentResponse paymentResp = requestBuilder.DomesticPayment()
                                                        .ConsentId(consentResp.Data.ConsentId)
                                                        .SubmitAsync().Result;

            //paymentResp.Should().NotBeNull();
            //paymentResp.Messages.Should().BeEmpty();
            //paymentResp.Data.Should().NotBeNull();

            // All done!
        }