Example #1
0
        private async void ShouldReturnNullWhenConsentIsNotFound()
        {
            var consentContext    = ConsentContext();
            var consentRepository = new ConsentRepository(consentContext);
            var consentAdded      = TestBuilder.Consent();
            await consentRepository.AddAsync(consentAdded);

            var consent = await consentRepository.GetFor("not-found-consent-id");

            consent.Should().BeNull();
        }
Example #2
0
        private async void ShouldFetchConsent()
        {
            var consentContext    = ConsentContext();
            var consentRepository = new ConsentRepository(consentContext);
            var consentAdded      = TestBuilder.Consent();
            await consentRepository.AddAsync(consentAdded);

            var consent = await consentRepository.GetFor(consentAdded.ConsentArtefactId);

            consent.Should().BeEquivalentTo(consentAdded);
        }
Example #3
0
        private async void ShouldStoreConsent()
        {
            var consentContext    = ConsentContext();
            var consentRepository = new ConsentRepository(consentContext);

            consentContext.ConsentArtefact.Count().Should().Be(0);

            await consentRepository.AddAsync(TestBuilder.Consent());

            consentContext.ConsentArtefact.Count().Should().Be(1);
        }
 public void EstablishConnection()
 {
     try
     {
         IOpenAPIRequestor requestor = new OpenAPIRequestor();
         requestor.PostAuthorisation("token");
         HttpResponseMessage response = requestor.PostConsentRequest("open-banking/v3.1/aisp/account-access-consents");
         if (response.IsSuccessStatusCode)
         {
             var resultString        = response.Content.ReadAsStringAsync().Result;
             IConsentRepository repo = new ConsentRepository();
             var consent             = repo.Get(resultString);
             AuthoriseConsent(consent.Data.ConsentId);
             requestor.PostAuthorisation("https://ob.natwest.useinfinite.io/token");
         }
     }
     catch (Exception e)
     {
         throw new HttpException(HttpStatusCode.InternalServerError, "Failure to establish connection to Banking Api");
     }
 }
 public ConsentRepositoryTests()
 {
     _repo = new ConsentRepository(ConnectionSettingsFactory.Create());
     RepoUtil.Reset(_repo);
 }
Example #6
0
 public ConsentRepositoryTests()
 {
     _repo = new ConsentRepository(TestFactory.SharedCollection, TestFactory.CreateConnectionSettings());
     RepoUtil.Reset(_repo);
 }
Example #7
0
        /// <inheritdoc />
        public ConsentRepositoryTests(ITestOutputHelper outputHelper, DatabaseFixture fixture) : base(outputHelper, fixture)
        {
            readContext   = CreateNewContextInSameTransaction();
            updateContext = CreateNewContextInSameTransaction();
            createContext = CreateNewContextInSameTransaction();


            study = createContext.Studies.Add(new StudyEntity {
                Name = Random.String()
            }).Entity;

            var consentedPerson = createContext.People.Add(new PersonEntity()).Entity;

            consentedStudySubject = createContext.Add(new StudySubjectEntity {
                Study = study, Person = consentedPerson, SubjectIdentifier = "Consented"
            }).Entity;
            createContext.Add(
                new ConsentEntity
            {
                StudySubject  = consentedStudySubject,
                DateProvided  = 1.December(1965),
                DateWithdrawn = 1.January(1966),
                GivenBy       = consentedPerson
            });

            activeConsent = createContext.Add(
                new ConsentEntity
            {
                StudySubject = consentedStudySubject,
                DateProvided = 1.February(1966),
                GivenBy      = consentedPerson
            }).Entity;

            var unconsentedPerson = createContext.People.Add(new PersonEntity()).Entity;

            createContext.Add(
                new StudySubjectEntity {
                Study = study, Person = unconsentedPerson, SubjectIdentifier = "Unconsented"
            });

            var withdrawnConsent = createContext.Add(new PersonEntity()).Entity;
            var withdrawnSubject = createContext.Add(
                new StudySubjectEntity {
                Study = study, Person = withdrawnConsent, SubjectIdentifier = "Withdrawn"
            }).Entity;

            withdrawnSubjectWithdrawnDate = 5.January(2018);
            createContext.Add(new ConsentEntity
            {
                StudySubject  = withdrawnSubject,
                DateProvided  = 1.December(2017),
                DateWithdrawn = withdrawnSubjectWithdrawnDate,
                GivenBy       = withdrawnConsent
            });


            createContext.SaveChanges();

            studyId             = new StudyIdentity(study.Id);
            consentedPersonId   = consentedPerson;
            unconsentedPersonId = unconsentedPerson;
            withdrawnPersonId   = withdrawnConsent;

            consents = CreateConsentRepository(readContext);

            studySubjects = CreateStudySubjectRepository(readContext);
            studies       = CreateStudyRepository(readContext);
        }