public void Test_IsOK() { using (TransactionScope scope = new TransactionScope()) { TitleTableAdapter tta = new TitleTableAdapter(); tta.Insert("test title", "test push message", "test dir", "test dir"); DataSet.TitleRow title = tta.GetDataByName("test title")[0]; CredentialTableAdapter cta = new CredentialTableAdapter(); DataSet.CredentialDataTable cdt = new DataSet.CredentialDataTable(); cdt.AddCredentialRow(title, Credential.LvlPackageNameKind, "org.kaoriha.flowerflower"); cta.Update(cdt); cdt.AddCredentialRow(title, Credential.LvlRsaKeyValueKind, "<RSAKeyValue><Modulus>lzqteVeU/xQAa5fNe6v/s+HZ2F6IZ953LG3tmKjW7JGzK9BJGaE+s5PZgd0ZFG+q9DWa80PQB2mxRaSoPZwe8ystMErjOoeFdXE5RVTXxBIu4YaqRAKTNcj5ki5qr2emalsBFU5w9CJHRCGta+0ByIR5KyCPvK6wgmDwLdG1MHPxLFgDXHcQmIDAwkhovD9thin9RvyVG4C2zeEwcynYHoEVBPtdeBGX4VxX6KkIGE7hxV1/BQt32j0xrX1luq7YBw9XOAlXehj9oMxg0ZGcYT9dD7CAYDOJvoOoKZL4dmyvBon249dUE2af+QrxfT6dGglRVIVlxaPBC6NixGOc+Q==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"); cta.Update(cdt); DateTime now = new DateTime(2011, 10, 14); LVLTableAdapter lta = new LVLTableAdapter(); DataSet.LVLDataTable ldt = new DataSet.LVLDataTable(); ldt.AddLVLRow(105002991, now); lta.Update(ldt); DataSet.LVLRow lvl = ldt[0]; Verifier v = new Verifier(lvl.Id, "3|105002991|org.kaoriha.flowerflower|1|ANlOHQM/Rs23FkGZEoX2p4DicHHRN68KEw==|1316406950698", "IuI1h8lefJGUfkXxleI7hERAiDBp0Rx8ItdKbUd/n9ObLA0odCfN3siqxd82I3MpgEJ6YL+zcK6dwHcjhioGN4nSI0rORIpTOrQt2zbsKWK7DAvlefeY3BDPTtm/73Z2gNVt1cv7RIaee/eVARMA8o0J5mxijoAkA6wybEW4fxpHZKG1sFH2UyNz8eZ1hEBg8YLi4yGKI2HNrTSgHgmTUXoT30qbjXf91jvqL2rSdtbHTHibDmKmu7kp+gk0H8eNRijmNwAQqoEGMPhqyv18tpth7UWNb0GnG0f+RYJDVyLhT84Iy+g3wN+JPjXGAADVVotOTTMuec113FlF1wvsIA==", now); Expect(v.IsOK(), Is.EqualTo(true)); Verifier v2 = new Verifier(lvl.Id, "1|105002991|org.kaoriha.flowerflower|1|ANlOHQM/Rs23FkGZEoX2p4DicHHRN68KEw==|1316406950698", "IuI1h8lefJGUfkXxleI7hERAiDBp0Rx8ItdKbUd/n9ObLA0odCfN3siqxd82I3MpgEJ6YL+zcK6dwHcjhioGN4nSI0rORIpTOrQt2zbsKWK7DAvlefeY3BDPTtm/73Z2gNVt1cv7RIaee/eVARMA8o0J5mxijoAkA6wybEW4fxpHZKG1sFH2UyNz8eZ1hEBg8YLi4yGKI2HNrTSgHgmTUXoT30qbjXf91jvqL2rSdtbHTHibDmKmu7kp+gk0H8eNRijmNwAQqoEGMPhqyv18tpth7UWNb0GnG0f+RYJDVyLhT84Iy+g3wN+JPjXGAADVVotOTTMuec113FlF1wvsIA==", now); Expect(v2.IsOK(), Is.EqualTo(false)); Verifier v3 = new Verifier(lvl.Id + 1, "3|105002991|org.kaoriha.flowerflower|1|ANlOHQM/Rs23FkGZEoX2p4DicHHRN68KEw==|1316406950698", "IuI1h8lefJGUfkXxleI7hERAiDBp0Rx8ItdKbUd/n9ObLA0odCfN3siqxd82I3MpgEJ6YL+zcK6dwHcjhioGN4nSI0rORIpTOrQt2zbsKWK7DAvlefeY3BDPTtm/73Z2gNVt1cv7RIaee/eVARMA8o0J5mxijoAkA6wybEW4fxpHZKG1sFH2UyNz8eZ1hEBg8YLi4yGKI2HNrTSgHgmTUXoT30qbjXf91jvqL2rSdtbHTHibDmKmu7kp+gk0H8eNRijmNwAQqoEGMPhqyv18tpth7UWNb0GnG0f+RYJDVyLhT84Iy+g3wN+JPjXGAADVVotOTTMuec113FlF1wvsIA==", now); Expect(v3.IsOK(), Is.EqualTo(false)); } }
public void Test_Properties() { using (TransactionScope scope = new TransactionScope()) { TitleTableAdapter tta = new TitleTableAdapter(); tta.Insert("test title", "test push message", basePath + @"\copyDirectory_dist", basePath + @"\copyDirectory_orig"); DataSet.TitleRow title = tta.GetDataByName("test title")[0]; SubscriberTableAdapter sta = new SubscriberTableAdapter(); sta.Insert(title.Id, "test authkey", "web", Constant.Ago); sta.Insert(title.Id, "test authkey 2", "web", new DateTime(2011, 10, 13)); DataSet.SubscriberDataTable sdt = sta.GetDataByTitleId(title.Id); DataSet.SubscriberRow s1, s2; if (sdt[0].AuthenticationKey == "test authkey") { s1 = sdt[0]; s2 = sdt[1]; } else { s2 = sdt[0]; s1 = sdt[1]; } TokenTableAdapter kta = new TokenTableAdapter(); kta.Insert(s1.Id, new DateTime(2011, 10, 12, 0, 0, 0), "deadbeef"); kta.Insert(s2.Id, new DateTime(2011, 10, 12, 4, 59, 50), "deadbeef2"); DataSet.TokenRow k1, k2; k1 = kta.GetDataByBody("deadbeef")[0]; k2 = kta.GetDataByBody("deadbeef2")[0]; Expect(SiteConstant.IsConfigurationOK, Is.EqualTo(true)); DateTime now = new DateTime(2011, 10, 12, 5, 0, 0); TokenPublisher p1 = new TokenPublisher(s1, now); DataSet.TokenRow pk1 = p1.Publish(); Expect(pk1.Id, Is.Not.EqualTo(k1.Id)); TokenPublisher p2 = new TokenPublisher(s2, now); DataSet.TokenRow pk2 = p2.Publish(); Expect(pk2.Id, Is.EqualTo(k2.Id)); kta.Insert(s2.Id, new DateTime(2011, 10, 12, 4, 59, 10), "deadbeef3"); kta.Insert(s2.Id, new DateTime(2011, 10, 12, 4, 59, 20), "deadbeef4"); TokenPublisher p2_2 = new TokenPublisher(s2, now); try { p2_2.Publish(); Expect(false); } catch (DoubtfulAuthBehaviorException) { // OK } Expect(kta.GetDataBySubscriberId(s2.Id).Count, Is.EqualTo(3)); } }
protected void Page_Load(object sender, EventArgs e) { TitleTableAdapter tta = new TitleTableAdapter(); DataSet.TitleRow title = tta.GetDataByName("debug title")[0]; SubscriberTableAdapter sta = new SubscriberTableAdapter(); DataSet.SubscriberDataTable sdt = sta.GetDataByTitleId(title.Id); if (sdt.Count == 0) { sdt.AddSubscriberRow(title, "debug auth key", AuthScheme.Web.ToString(), Constant.Ago); sta.Update(sdt); } subscriber = sdt[0]; }
static SiteConstant() { string title = ConfigurationManager.AppSettings["TitleName"]; if (title == null) { logger.Fatal("���̃T�C�g�̃^�C�g����web.config�ɐݒ肳��Ă��܂���B"); IsConfigurationOK = false; return; } string lr = ConfigurationManager.AppSettings["LvlResponseCodeShouldBe"]; if (lr == null || !int.TryParse(lr, out LvlResponseCodeShouldBe)) { logger.Fatal("LvlResponseCodeShouldBe��web.config�ɐݒ肳��Ă��Ȃ����A�l�������ł͂���܂���B"); IsConfigurationOK = false; return; } DataSet.TitleDataTable tdt; try { TitleTableAdapter ta = new TitleTableAdapter(); tdt = ta.GetDataByName(title); } catch (Exception e) { logger.Fatal("�f�[�^�x�[�X�ɃA�N�Z�X�ł��܂���B�f�[�^�x�[�X�̃A�J�E���g�Ɍ������Ȃ����A�܂��͐ڑ������Ԉ���Ă��܂�", e); IsConfigurationOK = false; return; } if (tdt.Count == 0) { logger.Fatal("web.config�ɐݒ肳��Ă��邱�̃T�C�g�̃^�C�g�����f�[�^�x�[�X��ɂ͑��݂��܂���B"); IsConfigurationOK = false; return; } SiteConstant.title = tdt[0]; credential = new Credential(Title); IsConfigurationOK = true; }
public void TestNotification() { logger.Info("test"); // Settings.TestSettings(typeof(NotificationServiceStub), null); using (TransactionScope scope = new TransactionScope()) { TitleTableAdapter tta = new TitleTableAdapter(); DataSet.TitleDataTable tdt = new DataSet.TitleDataTable(); tdt.AddTitleRow("test title", "test push message", "test site root path", "test standby path"); tta.Update(tdt); DataSet.TitleRow title = tdt[0]; CredentialTableAdapter cta = new CredentialTableAdapter(); DataSet.CredentialDataTable cdt = new DataSet.CredentialDataTable(); cdt.AddCredentialRow(title, Credential.ApnsPkcs12FilePathKind, SecureConstant.P12File); cta.Update(cdt); cdt.AddCredentialRow(title, Credential.ApnsPkcs12FilePasswordKind, SecureConstant.P12FilePassword); cta.Update(cdt); cdt.AddCredentialRow(title, Credential.LvlRsaKeyValueKind, "test lvlrsakeyvalue"); cta.Update(cdt); SubscriberTableAdapter sta = new SubscriberTableAdapter(); DataSet.SubscriberDataTable sdt = new DataSet.SubscriberDataTable(); sdt.AddSubscriberRow(title, "test authkey", "web", Constant.Ago); sta.Update(sdt); DataSet.SubscriberRow subscriber = sdt[0]; APNsTableAdapter ata = new APNsTableAdapter(); ata.Insert(subscriber.Id, "B9C83DAE377DDEEECB7C9EA662F7BFBC5D3FA95A5AD5E3CD4B0DD843E0D9EBED", false, 0, false); ApnsPusher p = ApnsPusher.GetInstance(title); p.PushReleaseNotification("test push message 2"); System.Threading.Thread.Sleep(10000); // �����ɏI������ƒʐM���Ԃɍ���Ȃ��i���ۂɑ��M����ꍇ�j DataSet.APNsDataTable adt = ata.GetDataByTitleId(title.Id); Expect(adt[0].UnreadRelease, Is.EqualTo(1)); } }
public void Test_ApnsFeedback() { Settings.TestSettings(null, typeof(FeedbackServiceStub)); using (TransactionScope scope = new TransactionScope()) { TitleTableAdapter tta = new TitleTableAdapter(); tta.Insert("test title", "test push message", "test site root path", "test standby path"); DataSet.TitleRow title = tta.GetDataByName("test title")[0]; SubscriberTableAdapter sta = new SubscriberTableAdapter(); sta.Insert(title.Id, "test authkey", "web", Constant.Ago); DataSet.SubscriberRow subscriber = sta.GetDataByTitleId(title.Id)[0]; APNsTableAdapter ata = new APNsTableAdapter(); ata.Insert(subscriber.Id, "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef", false, 0, false); ApnsFeedback fb = new ApnsFeedback(title); fb.Run(); DataSet.APNsDataTable adt = ata.GetDataByTitleId(title.Id); Expect(adt[0].Failed, Is.EqualTo(true)); } }
private DataSet.TitleRow PrepareBasic() { TitleTableAdapter tta = new TitleTableAdapter(); tta.Insert("test title", "test push message", "test site root path", "test standby path"); DataSet.TitleRow title = tta.GetDataByName("test title")[0]; CredentialTableAdapter cta = new CredentialTableAdapter(); DataSet.CredentialDataTable cdt = new DataSet.CredentialDataTable(); cdt.AddCredentialRow(title, Credential.ApnsPkcs12FilePathKind, "test pkcs12filepath"); cta.Update(cdt); cdt.AddCredentialRow(title, Credential.ApnsPkcs12FilePasswordKind, "test pkcs12filepassword"); cta.Update(cdt); SiteConstant.TestSettings(title); return title; }