public override void AfterTest(ITest test) { // ignore assemblies if (test != null && test.IsSuite && test.ClassName == null) { if (SharedSession != null) { FinalisingPrivateFixtures(test, SharedSession); } else { var authInfo = test.Properties.Get(TestInitAuthInfoPropertyName) as MultiItemAuthenticationInfo; var credentials = authInfo.Users.ContainsKey("mainUser") ? authInfo.Users["mainUser"] : authInfo.Users.First().Value; using (var session = GetClient(test.Id) .CreateSession(PrivateAuthentication.WithCredentials(credentials.Company.Name, credentials.Login, credentials.Password), InitSessionOptions())) { FinalisingPrivateFixtures(test, session); } } DisposeAuthenticationInfo(test); } if (init != null && test != null && init.Item2 == test.Id) { init.Item1.Dispose(); } base.AfterTest(test); }
private void InitialiseSingleConnection(ITest test) { if (test is TestFixture) { SingleConnectionAuthInfo = SingleConnectionAuthSpec == null ? AuthenticationInfoProvider.Current.DefaultAuthInfo : AuthenticationInfoProvider.Current.Manager.GetAuthenticationInfo(SingleConnectionAuthSpec); var credentials = SingleConnectionAuthInfo.Users.ContainsKey("mainUser") ? SingleConnectionAuthInfo.Users["mainUser"] : SingleConnectionAuthInfo.Users.First().Value; SharedSession = GetClient(test.Id).CreateSession(PrivateAuthentication.WithCredentials(credentials.Company.Name, credentials.Login, credentials.Password)); SharedSession.Authenticate(); var connection = new AuthApiConnection(); if (!((test.Properties.Get(TestCaseExAttribute.SuppressAuthenticationParameterName) as bool?).GetValueOrDefault(false))) { connection.Authenticate(SharedSession.Authentication().Session); } else { connection.SuppressAuthentication = true; } test.Properties.Add(AuthApiConnectionParameterName, connection); } else if (test is TestMethod) { ITest parentFixture = test.Parent; while (!(parentFixture is TestFixture)) { parentFixture = parentFixture.Parent; } test.Properties.Add(AuthApiConnectionParameterName, parentFixture.Properties.Get(AuthApiConnectionParameterName)); } }
public async Task ServerTest() { var req = FieldRequest.CreateFields(); req = req.Append(CreateFieldRequest.Builder().With(ResourceId.Activity, FieldType.Number, "test").Build().Content); var built = ((CreateFieldsRequest.IBuilderWithRecord)req).Build(); IPrivateClient client = PrivateClient.CreateClient(new PrivateServerSettings { ServerUrl = new Uri("http://namtest3-web.dynamic.ps.porters.local"), LoggerFactory = TestLoggerFactoryAttribute.CurrentLoggerFactory }); using (var session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password"))) { var fields = await session.CallAsync(built); Assume.That(fields.FieldFailed, Has.Count.EqualTo(0)); Assume.That(fields.FieldSuccess, Has.Count.GreaterThan(0)); var mapping = fields.FieldSuccess.ToDictionary(entry => entry.Value, entry => entry.Key); var res = await session.CallAsync(FieldRequest.GetFields().Select(FieldProperty.Name).WhereGuid(fields.FieldSuccess.Values)); var conv = res .ToDictionary(fieldEntry => mapping[(Guid)fieldEntry.Value[FieldProperty.Id]], fieldEntry => fieldEntry.Value); Assert.That(res, Has.Count.GreaterThan(0)); } }
/// <summary> /// Get PrivateSession /// </summary> /// <param name=""></param> public ISession <PrivateAuthentication> GetPrivateSession(string company, string username, string password) { if (_privateClient != null) { return(_privateClient.CreateSession(PrivateAuthentication.WithCredentials(company, username, password), null)); } return(null); }
public void SetUp() { string serverUrl = "http://namtest2-web.dynamic.ps.porters.local"; PrivateServerSettings settings = new PrivateServerSettings(); settings.ServerUrl = new Uri(serverUrl); client = PrivateClient.CreateClient(settings); session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password")); Assume.That(session.Authenticate(), Is.True, "Cannot login to the server!"); }
public AuthResponseCode Unsubscribe(string appId, string redirectUrl, string scope, string companyName, string login, string password, bool doLoginInAdvance = true) { if (doLoginInAdvance) { using (var privateApiSession = DoLogin(companyName, login, password)) { return(Unsubscribe(appId, redirectUrl, scope, privateApiSession.Authentication())); } } return(Unsubscribe(appId, redirectUrl, scope, privateApiAuthData: PrivateAuthentication.WithCredentials(companyName, login, password))); }
public void TestPrivateAuthenticationSuccess() { IPrivateClient client = PrivateClient.CreateClient(new PrivateServerSettings { ServerUrl = new Uri("http://namtest3-web.dynamic.ps.porters.local") }); using (var session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password"))) { var result = session.Call(MetaDataRequest.LastUpdated(1)); Assert.That(result.LastUpdateDate, Is.GreaterThan(0)); } }
public async Task UpdateSingleField() { IPrivateClient client = PrivateClient.CreateClient(new PrivateServerSettings { ServerUrl = new Uri("http://namtest2-web.dynamic.ps.porters.local"), LoggerFactory = TestLoggerFactoryAttribute.CurrentLoggerFactory }); using (var session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password"))) { var req = await session.CallAsync(FieldRequest.UpdateField().Field("Client.P_Name".ToField()).Label("Woof")); Assert.That(req); } }
public async Task DeleteSingleRecordI() { using (var client = PrivateClient.CreateClient(new PrivateServerSettings() { ServerUrl = new Uri("http://deletetest-web.dynamic.ps.porters.local"), LoggerFactory = TestLoggerFactoryAttribute.CurrentLoggerFactory })) using (var session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password"))) { var request = DeleteRecordRequest.Builder().Append(ResourceId.Process, 10001, 10002); var response = await session.CallAsync(request); Assert.That(response.DeletedRecords, Has.Count.EqualTo(1)); Assert.That(response.DeletedRecords.Keys, Does.Contain(ResourceId.Process)); Assert.That(response.DeletedRecords[ResourceId.Process], Has.Count.EqualTo(2)); Assert.That(response.DeletedRecords[ResourceId.Process], Does.Contain(10001)); Assert.That(response.DeletedRecords[ResourceId.Process], Does.Contain(10002)); } }
public async Task CreateSingleRecordOnServer() { using (var client = PrivateClient.CreateClient(new PrivateServerSettings() { ServerUrl = new Uri("http://namtest2-web.dynamic.ps.porters.local"), LoggerFactory = TestLoggerFactoryAttribute.CurrentLoggerFactory })) using (var session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password"))) { var request = ResourceRequest.CreateRecords() .Append(ResourceId.Recruiter, builder => builder.Append("P_Name", "test record 3").Append("P_Client", new CreateRecordRequest.Reference("key1")).Append("P_Owner", 1), "req1") .Append(ResourceId.Client, builder => builder.Append("P_Name", "test record").Append("P_Owner", 1), "key1") .Append(ResourceId.Client, builder => builder.Append("P_Name", "test record 2").Append("P_Owner", 1), "key2") .Append(ResourceId.Client, builder => builder.Append("P_Name", "test record 3").Append("P_Owner", 1), "key3") .Build(); var response = await session.CallAsync(request); Assert.That(response.Errors, Is.Empty); Assert.That(response.RecordIds, Has.Count.EqualTo(4)); } }
public override void BeforeTest(ITest test) { var client = GetClient(test.Id); // ignore assemblies if (test.IsSuite && test.ClassName == null) { return; } List <AggregateException> errors = new List <AggregateException>(); var authInfo = GetInitialisationAuthData(test); var credentials = authInfo.Users.ContainsKey("mainUser") ? authInfo.Users["mainUser"] : authInfo.Users.First().Value; test.Properties.Add(TestInitAuthInfoPropertyName, authInfo); if (SharedSession != null) { PreparingPrivateFixtures(test, errors, SharedSession); } else { using (var session = GetClient(test.Id) .CreateSession(PrivateAuthentication.WithCredentials(credentials.Company.Name, credentials.Login, credentials.Password), InitSessionOptions())) { PreparingPrivateFixtures(test, errors, session); } } if (test is NUnit.Framework.Internal.TestMethod) // store auth info only for test cases, not for test fixtures { test.Properties.Add(TestAuthInfoPropertyName, GetTestAuthData(test)); } if (errors.Count > 0) { Assume.That(errors, Is.Empty, $"Data Fixture Creation Error: {errors.Select(ex => ex.Message).Aggregate((a, b) => $"{a}, {b}")}"); } base.BeforeTest(test); }
public async Task RetrievesData() { PrivateClient client = PrivateClient.CreateClient(new PrivateServerSettings { ServerUrl = new Uri("http://arwyntest-web.dynamic.ps.porters.local") }); using (PrivateSession session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password"))) { var request = ResourceRequest.GetRecords(ResourceId.Process) .WithFields(FieldCollection.Builder() .Append("Process.P_PhaseMemo".ToField()) .Build()) .WithRecords(10003); var result = await session.CallAsync(request); Assert.That(result.RecordData.Count, Is.EqualTo(1)); Assert.That(result.RecordData.First().Version, Is.EqualTo(1)); Assert.That(result.RecordData.First().Count, Is.EqualTo(2)); Assert.That(result.RecordData.First().RecordId, Is.EqualTo(10003)); Assert.That(result.RecordData.First()["Process.P_PhaseMemo".ToField()], Is.EqualTo("サンプル選考プロセスメモ")); } }