예제 #1
0
        public void IntegrationTest_TrustRelation_RequestWithAutoResponse()
        {
            var providerFactory = ProviderFactory.Instance;
            var typeProvider    = providerFactory.CreateTrustRelationTypeServiceProvider();


            var builder = new TrustRelationRequestBuilder();

            builder.SetFromTenant(_sourceTenant.ID).SetToTenant(_targetTenant.ID);
            builder.SetMessage("TestMsg").SetTitle("title").SetLanguageISO("en");
            builder.AddOfferedTrustType(_trustRelationType.ID).AddRequestedTrustType(_trustRelationType.ID);

            var request         = builder.Build();
            var requestProvider = providerFactory.CreateTrustRelationRequestServiceProvider();

            requestProvider.SendTrustRelationRequest(request, true);
            Thread.Sleep(1000);


            var incomingReqests = requestProvider.GetAllIncomingTrustRelationRequests(_targetTenant.ID);

            Assert.AreEqual(1, incomingReqests.Count);
            Assert.AreEqual(TrustRequestStatus.Accepted, incomingReqests[0].Status);

            var outgoingReqests = requestProvider.GetAllOutgoingTrustRelationRequests(_sourceTenant.ID);

            Assert.AreEqual(1, outgoingReqests.Count);
            Assert.AreEqual(TrustRequestStatus.Accepted, outgoingReqests[0].Status);
        }
예제 #2
0
        public void TestSendTrustRelationRequestValid()
        {
            var builder = new TrustRelationRequestBuilder();

            builder.SetAutoApproved(true).SetFromTenant(Guid.NewGuid()).SetToTenant(Guid.NewGuid()).SetInvitationCode("test");
            var request = builder.Build();

            var tenantID  = Guid.NewGuid();
            var requestID = Guid.NewGuid();
            IRestResponse <Dictionary <String, String> > creationMockedResponse = new RestResponse <Dictionary <String, String> >()
            {
                StatusCode = System.Net.HttpStatusCode.Created
            };

            creationMockedResponse.Data         = new Dictionary <string, string>();
            creationMockedResponse.Data["code"] = Guid.NewGuid().ToString();
            mockedClient.Setup <IRestResponse>(c => c.Execute <Dictionary <String, String> >(It.IsAny <JSONRestRequest>())).Returns(creationMockedResponse);

            IRestResponse <TrustRelationRequest> retrievalMockedResponse = new RestResponse <TrustRelationRequest>()
            {
                StatusCode = System.Net.HttpStatusCode.OK
            };

            retrievalMockedResponse.Data = new TrustRelationRequest();
            mockedClient.Setup <IRestResponse>(c => c.Execute <TrustRelationRequest>(It.IsAny <JSONRestRequest>())).Returns(retrievalMockedResponse);
            var result = provider.SendTrustRelationRequest(request, true);

            Assert.AreEqual(request.Code, request.Code);
            Assert.AreEqual(request.FromTenant, request.FromTenant);
            Assert.AreEqual(request.ToTenant, request.ToTenant);
            //TODO: Implement rest of the check

            mockedClient.Verify(c => c.Execute <Dictionary <String, String> >(It.IsAny <JSONRestRequest>()), Times.Once);
            mockedClient.Verify(c => c.Execute <TrustRelationRequest>(It.IsAny <JSONRestRequest>()), Times.Once);
        }
예제 #3
0
 public void IntegrationTest_TrustRelation_TestErrorHandling()
 {
     try
     {
         var provider = ProviderFactory.Instance.CreateTrustRelationRequestServiceProvider();
         var builder  = new TrustRelationRequestBuilder();
         builder.SetFromTenant(Guid.Empty);
         var request = builder.Build();
         provider.SendTrustRelationRequest(request);
     }
     catch (SDKServiceException ex)
     {
         Assert.AreEqual(ex.ServerResponseCode, System.Net.HttpStatusCode.BadRequest);
         //Should throw exception
     }
 }