<?php

$_app = 'pc_backend';
include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../bootstrap/database.php';
$browser = new opTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color()));
$browser->info('Login')->get('/default/login')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')))->isStatusCode(302)->info('/opDiaryPlugin/index - CSRF')->post('/opDiaryPlugin/index')->checkCSRF();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../bootstrap/database.php';
$_app = 'pc_backend';
$browser = new opTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color()));
$browser->info('Login')->get('/default/login')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')))->isStatusCode(302)->info('/communityTopic/topicDelete/id/1 - CSRF')->post('/communityTopic/topicDelete/id/1')->checkCSRF()->info('/communityTopic/topicCommentDelete/id/1 - CSRF')->post('/communityTopic/topicCommentDelete/id/1')->checkCSRF()->info('/communityTopic/eventDelete/id/1 - CSRF')->post('/communityTopic/eventDelete/id/1')->checkCSRF()->info('/communityTopic/eventCommentDelete/id/1 - CSRF')->post('/communityTopic/eventCommentDelete/id/1')->checkCSRF()->info('/communityTopic/eventMemberDelete/id/1 - CSRF')->post('/communityTopic/eventMemberDelete/id/1')->checkCSRF()->info('/opCommunityTopicPlugin/index - CSRF')->post('/opCommunityTopicPlugin/index')->checkCSRF()->info('/communityTopic/index - XSS')->get('/communityTopic/index')->click('検索', array('communityTopic' => array('name' => array('text' => 'CommunityTopic.name'))))->with('html_escape')->begin()->isAllEscapedData('CommunityTopic', 'name')->isAllEscapedData('CommunityTopic', 'body')->end()->info('/communityTopic/topicCommentList - XSS')->get('/communityTopic/topicCommentList')->click('検索', array('communityTopicComment' => array('member_name' => 'Member.name')))->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('CommunityTopicComment', 'body')->end()->info('/communityTopic/eventList - XSS')->get('/communityTopic/eventList')->click('検索', array('communityEvent' => array('name' => array('text' => 'CommunityEvent.name'))))->with('html_escape')->begin()->isAllEscapedData('CommunityEvent', 'name')->isAllEscapedData('CommunityEvent', 'body')->end()->info('/communityTopic/eventCommentList - XSS')->get('/communityTopic/eventCommentList')->click('検索', array('communityEventComment' => array('member_name' => 'Member.name')))->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('CommunityEventComment', 'body')->end()->info('/communityTopic/eventMemberList - XSS')->get('/communityTopic/eventMemberList')->click('検索', array('communityEventMember' => array('member_name' => array('text' => 'Member.name'))))->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('CommunityEvent', 'name')->end()->info('/communityTopic/topicDelete/id/1055 - XSS')->get('/communityTopic/topicDelete/id/1055')->with('html_escape')->begin()->isAllEscapedData('CommunityTopic', 'name')->isAllEscapedData('CommunityTopic', 'body')->end()->info('/communityTopic/topicCommentDelete/id/1055 - XSS')->get('/communityTopic/topicCommentDelete/id/1055')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('CommunityTopicComment', 'body')->end()->info('/communityTopic/eventDelete/id/1055 - XSS')->get('/communityTopic/eventDelete/id/1055')->with('html_escape')->begin()->isAllEscapedData('CommunityEvent', 'name')->isAllEscapedData('CommunityEvent', 'body')->end()->info('/communityTopic/eventCommentDelete/id/1055 - XSS')->get('/communityTopic/eventCommentDelete/id/1055')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('CommunityEventComment', 'body')->end()->info('/communityTopic/eventMemberDelete/id/1055 - XSS')->get('/communityTopic/eventMemberDelete/id/1055')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('CommunityEvent', 'name')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$test = new opTestFunctional(new sfBrowser());
include dirname(__FILE__) . '/../../bootstrap/database.php';
$test->setCulture('en');
Doctrine::getTable('SnsConfig')->set('op_diary_plugin_use_open_diary', '0');
$test->info('isSecure Test')->get('/diary')->isForwardedTo('member', 'login')->get('/diary/list')->isForwardedTo('member', 'login')->get('/diary/search', array('keyword' => 'hoge'))->isForwardedTo('member', 'login')->get('/diary/3')->isForwardedTo('member', 'login')->get('/diary/listMember/5')->isForwardedTo('member', 'login')->get('/diary/listMember/5/2009/6')->isForwardedTo('member', 'login')->get('/diary/listMember/5/2009/6/1')->isForwardedTo('member', 'login');
Doctrine::getTable('SnsConfig')->set('op_diary_plugin_use_open_diary', '1');
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../bootstrap/database.php';
$browser = new opTestFunctional(new sfBrowser());
$browser->login('*****@*****.**', 'password');
// CSRF
$browser->info('/album/create - CSRF')->post('/album/create')->checkCSRF()->info('/album/update/1055 - CSRF')->post('/album/update/1055')->checkCSRF()->info('/album/delete/1055 - CSRF')->post('/album/delete/1055')->checkCSRF()->info('/member/home - XSS')->get('/member/home')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('Album', 'title')->end()->info('/album - XSS')->get('/album')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->countEscapedData(2, 'Album', 'title', array('width' => 36))->countEscapedData(2, 'Album', 'body', array('width' => 36))->end()->info('/album/listFriend - XSS')->get('/album/listFriend')->with('html_escape')->begin()->isAllEscapedData('Album', 'title')->countEscapedData(1, 'Album', 'body', array('width' => 36))->end()->info('/album/listMember - XSS')->get('/album/listMember')->with('html_escape')->begin()->isAllEscapedData('Album', 'title')->countEscapedData(1, 'Album', 'body', array('width' => 36))->end()->info('/album/1055 - XSS')->get('/album/1055')->with('html_escape')->begin()->isAllEscapedData('Album', 'title')->countEscapedData(1, 'Album', 'body', array('width' => 36))->end()->login('*****@*****.**', 'password')->info('/member/1055 - XSS')->get('/member/1055')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('Album', 'title')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new opTestFunctional(new sfBrowser(), new lime_test(null, new lime_output_color()));
$browser->info('Login')->get('/default/login')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')))->isStatusCode(302)->info('/connection - CSRF')->post('/connection')->checkCSRF()->info('/connection/1 - CSRF')->post('/connection/1')->checkCSRF()->info('/connection/1/delete - CSRF')->post('/connection/1/delete')->checkCSRF()->info('//connection/removeToken/id/1 - CSRF')->post('/connection/removeToken/id/1')->checkCSRF();
<?php

$app = 'pc_backend';
include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new opTestFunctional(new opBrowser(), new lime_test(8, new lime_output_color()));
$browser->info('Login')->get('/default/login')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')))->isStatusCode(302)->info('/monitoring/album/image/delete/1055 - CSRF')->post('/monitoring/album/image/delete/1055')->checkCSRF()->info('/monitoring/album/image/search - XSS')->get('/monitoring/album/image/search', array('keyword' => 'AlbumImage.description'))->with('html_escape')->begin()->isAllEscapedData('Album', 'title')->isAllEscapedData('Member', 'name')->isAllEscapedData('AlbumImage', 'description')->end()->info('/monitoring/album/image/deleteConfirm/1055 - XSS')->get('/monitoring/album/image/deleteConfirm/1055', array('keyword' => 'AlbumImage.description'))->with('html_escape')->begin()->isAllEscapedData('Album', 'title')->isAllEscapedData('Member', 'name')->isAllEscapedData('AlbumImage', 'description')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new opTestFunctional(new sfBrowser(), new lime_test(null, new lime_output_color()));
include dirname(__FILE__) . '/../../bootstrap/database.php';
$browser->login('*****@*****.**', 'password');
$browser->setCulture('en');
$browser->get('/')->with('user')->isAuthenticated();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$t = new opTestFunctional(new sfBrowser());
include dirname(__FILE__) . '/../../bootstrap/database.php';
$topicId = 1;
$comments = Doctrine::getTable('CommunityTopicComment')->createQuery('q')->where('community_topic_id = ?', $topicId)->execute();
$t->info('should fetch a list of comments ');
$json = $t->post('/topic_comment/search.json', array('apiKey' => 'dummyApiKey', 'community_topic_id' => $topicId))->getResponse()->getContent();
$data = json_decode($json, true);
$t->test()->is($data['status'], 'success', 'should return status code "success"');
$t->test()->is(count($data['data']), count($comments), 'should have ' . count($comments) . ' comments');
$t->test()->ok(count($data['data'][0]['deletable']), 'should have deletable property');
$t->info('should be able to limit the number of comment');
$json = $t->post('/topic_comment/search.json', array('apiKey' => 'dummyApiKey', 'community_topic_id' => $topicId, 'count' => 5))->getResponse()->getContent();
$data = json_decode($json, true);
$t->test()->is($data['status'], 'success', 'should return status code "success"');
$t->test()->is(count($data['data']), 5, 'should have 5 comments');
$t->test()->ok(count($data['data'][0]['deletable']), 'should have deletable property');
$t->info('should return comments with parameters, max_id and since_id');
$json = $t->post('/topic_comment/search.json', array('apiKey' => 'dummyApiKey', 'community_topic_id' => $topicId, 'max_id' => 4, 'since_id' => 1))->getResponse()->getContent();
$data = json_decode($json, true);
$t->test()->is($data['status'], 'success', 'should return status code "success"');
$t->test()->is(count($data['data']), 2, 'should return 2 topics');
$t->test()->is($data['data'][0]['id'], '4', 'data 0 should have topic 4 ');
$t->test()->is($data['data'][1]['id'], '2', 'data 2 should have topic 3 ');
$t->info('non-members should not be able to fetch a list of comments ');
$json = $t->post('/topic_comment/search.json', array('apiKey' => 'dummyApiKey4', 'community_topic_id' => $topicId))->with('response')->begin()->isStatusCode('400')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$test = new opTestFunctional(new sfBrowser());
$test->setMobile();
include dirname(__FILE__) . '/../../bootstrap/database.php';
$test->login('*****@*****.**', 'password');
$test->setCulture('en');
$test->info('Diary Comment History Test')->get('/diary/comment/history')->with('request')->begin()->isParameter('module', 'diaryComment')->isParameter('action', 'history')->end()->with('response')->begin()->checkElement('center', "\n" . '1 - 20 of 21')->checkElement('center a', 'Next')->end()->click('Next')->with('request')->begin()->isParameter('module', 'diaryComment')->isParameter('action', 'history')->isParameter('page', 2)->end()->with('response')->begin()->checkElement('center', "\n" . '21 - 21 of 21')->checkElement('center a', 'Previous')->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diaryComment')->isParameter('action', 'history')->end()->with('response')->begin()->checkElement('center', "\n" . '1 - 20 of 21')->checkElement('center a', 'Next')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new opTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color()));
$browser->info('0. Login')->get('/member/login')->click('ログイン', array('authMailAddress' => array('mail_address' => '*****@*****.**', 'password' => 'password')))->isStatusCode(302)->info('1. Community list is shown on the member\'s home.')->get('member/home');
$selector = new sfDomCssSelector($browser->getResponseDom());
$list = $selector->matchAll('#Left h3:contains("コミュニティリスト")')->getNodes();
$browser->test()->ok($list, 'a community list gadget exists');
$photoLink = '';
$textLink = '';
$xpath = new DOMXPath($browser->getResponseDom());
foreach ($xpath->query('../../table/tr', $list[0]) as $item) {
    if ($item->getAttribute('class') === 'photo') {
        $photoLink = $item->firstChild->getElementsByTagName('a')->item(0)->getAttribute('href');
    } elseif ($item->getAttribute('class') === 'text') {
        $textLink = $item->firstChild->getElementsByTagName('a')->item(0)->getAttribute('href');
    }
}
$browser->test()->ok($photoLink, 'photo link exists');
$browser->test()->ok($textLink, 'text link exists');
$browser->info('links in a community list is a valid (ref. #3546)')->info('photo link is a valid')->get($photoLink)->isStatusCode(200)->with('request')->begin()->isParameter('module', 'community')->isParameter('action', 'home')->end()->info('text link is a valid')->get($textLink)->isStatusCode(200)->with('request')->begin()->isParameter('module', 'community')->isParameter('action', 'home')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../bootstrap/database.php';
include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new opTestFunctional(new opBrowser(), new lime_test(50, new lime_output_color()));
$browser->login('*****@*****.**', 'password')->info('/communityEvent/create - CSRF')->post('/communityEvent/create/1055')->checkCSRF()->info('/communityEvent/delete - CSRF')->post('/communityEvent/delete/1055')->checkCSRF()->info('/communityEvent/update - CSRF')->post('/communityEvent/update/1055')->checkCSRF()->info('/communityEventComment/create - CSRF')->post('/communityEvent/1055/comment/create')->checkCSRF()->info('/communityEventComment/delete - CSRF')->post('/communityEvent/comment/delete/1055')->checkCSRF()->info('/communityTopic/create - CSRF')->post('/communityTopic/create/1055')->checkCSRF()->info('/communityTopic/delete - CSRF')->post('/communityTopic/delete/1055')->checkCSRF()->info('/communityTopic/update - CSRF')->post('/communityTopic/update/1055')->checkCSRF()->info('/communityTopicComment/create - CSRF')->post('/communityTopic/1055/comment/create')->checkCSRF()->info('/communityTopicComment/delete - CSRF')->post('/communityTopic/comment/delete/1055')->checkCSRF()->info('/communityTopic/configNotificationMail - CSRF')->post('/config/communityTopicNotificationMail/1055', array('topic_notify' => array()))->followRedirect()->checkCSRF()->info('/communityEvent/edit - XSS')->get('/communityEvent/edit/1055')->with('html_escape')->begin()->isAllEscapedData('CommunityEvent', 'name')->isAllEscapedData('CommunityEvent', 'body')->isAllEscapedData('CommunityEvent', 'open_date_comment')->isAllEscapedData('CommunityEvent', 'area')->end()->info('/communityEvent/listCommunity - XSS')->get('/communityEvent/listCommunity/1055')->with('html_escape')->begin()->isAllEscapedData('CommunityEvent', 'name')->end()->info('/communityEvent/memberList - XSS')->get('/communityEvent/1055/memberList')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->end()->info('/communityEvent/recentlyEventList - XSS')->get('/communityEvent/recentlyEventList')->with('html_escape')->begin()->isAllEscapedData('Community', 'name')->isAllEscapedData('CommunityEvent', 'name')->end()->info('/communityEvent/show - XSS')->get('/communityEvent/1055')->with('html_escape')->begin()->isAllEscapedData('CommunityEvent', 'name')->isAllEscapedData('CommunityEvent', 'body')->isAllEscapedData('CommunityEvent', 'open_date_comment')->isAllEscapedData('CommunityEvent', 'area')->isAllEscapedData('CommunityEventComment', 'body')->isAllEscapedData('Member', 'name')->end()->info('/communityTopic/edit - XSS')->get('/communityTopic/edit/1055')->with('html_escape')->begin()->isAllEscapedData('CommunityTopic', 'name')->isAllEscapedData('CommunityTopic', 'body')->end()->info('/communityTopic/listCommunity - XSS')->get('/communityTopic/listCommunity/1055')->with('html_escape')->begin()->isAllEscapedData('CommunityTopic', 'name')->end()->info('/communityTopic/recentlyTopicList - XSS')->get('/communityTopic/recentlyTopicList')->with('html_escape')->begin()->isAllEscapedData('Community', 'name')->isAllEscapedData('CommunityTopic', 'name')->end()->info('/communityTopic/show - XSS')->get('/communityTopic/1055')->with('html_escape')->begin()->isAllEscapedData('CommunityTopic', 'name')->isAllEscapedData('CommunityTopic', 'body')->isAllEscapedData('Member', 'name')->end()->info('/communityTopic/search - XSS')->get('/communityTopic/search', array('type' => 'topic', 'keyword' => opTesterHtmlEscape::getRawTestData('CommunityTopic', 'name')))->with('html_escape')->begin()->isAllEscapedData('CommunityTopic', 'name')->countEscapedData(1, 'Community', 'name', array('width' => 36, 'etc' => '', 'rows' => 3))->countEscapedData(1, 'CommunityTopic', 'body', array('width' => 36, 'etc' => '', 'rows' => 3))->end()->get('/communityTopic/search', array('type' => 'event', 'keyword' => opTesterHtmlEscape::getRawTestData('CommunityEvent', 'name')))->with('html_escape')->begin()->isAllEscapedData('CommunityEvent', 'name')->countEscapedData(1, 'Community', 'name', array('width' => 36, 'etc' => '', 'rows' => 3))->countEscapedData(1, 'CommunityEvent', 'body', array('width' => 36, 'etc' => '', 'rows' => 3))->end()->get('/communityTopic/search/1055', array('type' => 'topic', 'keyword' => opTesterHtmlEscape::getRawTestData('CommunityTopic', 'name')))->with('html_escape')->begin()->isAllEscapedData('CommunityTopic', 'name')->countEscapedData(1, 'Community', 'name', array('width' => 36, 'etc' => '', 'rows' => 3))->countEscapedData(1, 'CommunityTopic', 'body', array('width' => 36, 'etc' => '', 'rows' => 3))->end()->get('/communityTopic/search/1055', array('type' => 'event', 'keyword' => opTesterHtmlEscape::getRawTestData('CommunityEvent', 'name')))->with('html_escape')->begin()->isAllEscapedData('CommunityEvent', 'name')->countEscapedData(1, 'Community', 'name', array('width' => 36, 'etc' => '', 'rows' => 3))->countEscapedData(1, 'CommunityEvent', 'body', array('width' => 36, 'etc' => '', 'rows' => 3))->end()->info('/communityEvent/_communityEventList, /communityTopic/_communityTopicList - XSS')->get('/community/1055')->with('html_escape')->begin()->countEscapedData(1, 'CommunityEvent', 'name', array('width' => 36))->countEscapedData(1, 'CommunityTopic', 'name', array('width' => 36))->end()->info('/communityEvent/_eventCommentListBox, /communityTopic/_topicCommentListBox - XSS')->get('/')->with('html_escape')->begin()->isAllEscapedData('Community', 'name')->countEscapedData(1, 'CommunityEvent', 'name', array('width' => 36))->countEscapedData(1, 'CommunityTopic', 'name', array('width' => 36))->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$test = new opTestFunctional(new sfBrowser());
$test->setMobile();
include dirname(__FILE__) . '/../../bootstrap/database.php';
$test->setCulture('en');
$test->info('isSecure Test')->get('/diary')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'index')->end()->get('/diary/list')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'list')->end()->get('/diary/search', array('keyword' => 'hoge'))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->end()->get('/diary/3')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'show')->isParameter('id', 3)->end()->get('/diary/listMember')->with('response')->isStatusCode(404)->get('/diary/listMember/5')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 5)->end()->get('/diary/listMember/5/2009/6')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 5)->isParameter('year', 2009)->isParameter('month', 6)->end()->get('/diary/listMember/5/2009/6/1')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 5)->isParameter('year', 2009)->isParameter('month', 6)->isParameter('day', 1)->end()->get('/diary/new')->isForwardedTo('member', 'login')->post('/diary/create')->isForwardedTo('member', 'login')->get('/diary/edit/1')->isForwardedTo('member', 'login')->post('/diary/update/1')->isForwardedTo('member', 'login')->get('/diary/deleteConfirm/1')->isForwardedTo('member', 'login')->post('/diary/delete/1')->isForwardedTo('member', 'login')->post('/diary/1/comment/create')->isForwardedTo('member', 'login')->get('/diary/comment/deleteConfirm/1')->isForwardedTo('member', 'login')->post('/diary/comment/delete/1')->isForwardedTo('member', 'login');
$test->info('Public Flag Test')->get('/diary/1')->with('response')->isStatusCode(404)->get('/diary/3')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'show')->isParameter('id', 3)->end();
$test->info('Show Test')->get('diary/list')->click('Open Diary30(0)')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'show')->end()->with('response')->begin()->checkElement('center a', 1)->checkElement('center a', 'Previous Diary')->checkElement('#formDiaryComment', false)->end();
$keyword = 'Open';
$test->info('Search Test: ' . $keyword)->get('diary/list')->click('Search', array('keyword' => $keyword))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->end()->with('response')->begin()->checkElement('center', "\n" . '1 - 20 of 30')->checkElement('center a', 'Next')->checkElement('td a', 'Search Results')->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->isParameter('page', 2)->end()->with('response')->begin()->checkElement('center', "\n" . '21 - 30 of 30')->checkElement('center a', 'Previous')->checkElement('td a', 'Search Results')->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->isParameter('page', 1)->end()->with('response')->begin()->checkElement('center', "\n" . '1 - 20 of 30')->checkElement('center a', 'Next')->checkElement('td a', 'Search Results')->end();
$keyword = 'tititi';
$test->info('Search Test: ' . $keyword)->get('diary/list')->click('Search', array('keyword' => $keyword))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->end()->with('response')->begin()->checkElement('td a', 'Search Results')->matches('/Your search "' . $keyword . '" did not match any diaries\\./')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$test = new opTestFunctional(new sfBrowser());
include dirname(__FILE__) . '/../../bootstrap/database.php';
$test->login('*****@*****.**', 'password');
$test->setCulture('en');
$test->info('Search Test')->get('/diary/list')->with('response')->begin()->checkElement('#diarySearchFormLine', true)->end();
$keyword = 'tititi';
$test->info('Search Test: ' . $keyword)->click('Search', array('keyword' => $keyword))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 51')->checkElement('.pagerRelative .prev', 0)->checkElement('.pagerRelative .next', 2)->checkElement('.partsHeading h3', 'Search Results')->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 40 of 51')->checkElement('.pagerRelative .prev', 2)->checkElement('.pagerRelative .next', 2)->checkElement('.partsHeading h3', 'Search Results')->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->isParameter('page', 1)->end();
$keyword = '日本語';
$test->info('Search Test: ' . $keyword)->click('Search', array('keyword' => $keyword))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 21')->checkElement('.pagerRelative .prev', 0)->checkElement('.pagerRelative .next', 2)->checkElement('.partsHeading h3', 'Search Results')->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 21 of 21')->checkElement('.pagerRelative .prev', 2)->checkElement('.pagerRelative .next', 0)->checkElement('.partsHeading h3', 'Search Results')->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->isParameter('page', 1)->end();
$keyword = 'NoMatchingWord';
$test->info('Search Test: ' . $keyword)->click('Search', array('keyword' => $keyword))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'search')->isParameter('keyword', $keyword)->end()->with('response')->begin()->checkElement('.pagerRelative', 0)->checkElement('.partsHeading h3', 'Search Results')->checkElement('#diaryList div.body', "\n" . 'Your search "NoMatchingWord" did not match any diaries.')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$t = new opTestFunctional(new sfBrowser());
include dirname(__FILE__) . '/../../bootstrap/database.php';
$mailAddress = '*****@*****.**';
$t->login($mailAddress, 'password');
$t->setCulture('en');
$apiKey = '?apiKey=dummyApiKey';
$t->info('for the first thing, post a entry to delete afterwords');
$title = 'テストタイトル';
$body = 'テスト本文';
$publicFlag = 1;
//全員に公開
$json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'body' => $body, 'public_flag' => $publicFlag))->getResponse()->getContent();
$data = json_decode($json, true);
$t->test()->is($data['status'], 'success', 'should return status code "success"');
$t->test()->ok($data['data']['id'], 'should have id');
$t->test()->ok($data['data']['member'], 'should have member info');
$t->test()->is($data['data']['title'], $title, 'should have the same title posted');
$t->test()->is($data['data']['body'], $body, 'should have the same body posted');
$t->test()->is($data['data']['public_flag'], $publicFlag, 'should have the same publid flag posted');
$t->test()->ok($data['data']['created_at'], 'should have the date posted');
$deleteId = $data['data']['id'];
$json = '';
$data = array();
$t->info('should be able to delete the entry');
$json = $t->post('/diary/delete.json', array('apiKey' => 'dummyApiKey', 'id' => $deleteId))->getResponse()->getContent();
$data = json_decode($json, true);
var_dump($data, $json);
$t->test()->is($data['status'], 'success', 'should return status code "success"');
<?php

$app = 'pc_backend';
include dirname(__FILE__) . '/../../bootstrap/functional.php';
$xssApp = Doctrine::getTable('Application')->findOneByUrl('http://example.com/dummy4.xml');
$connection = Doctrine::getTable('Application')->getConnection();
$connection->beginTransaction();
$browser = new opBrowser();
$user = new opTestFunctional($browser, new lime_test(25, new lime_output_color()));
$user->info('login')->get('/')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')));
$user->info('opOpenSocialPlugin')->post('opOpenSocialPlugin', array())->checkCSRF();
$user->info('opOpenSocialPlugin/containerConfig')->post('opOpenSocialPlugin/containerConfig', array())->checkCSRF();
$user->info('opOpenSocialPlugin/add')->post('opOpenSocialPlugin/add', array())->checkCSRF();
$user->info('opOpenSocialPlugin/list')->get('opOpenSocialPlugin/list')->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->end();
$user->info('opOpenSocialPlugin/info')->get('opOpenSocialPlugin/info/' . $xssApp->id)->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->isAllEscapedData('ApplicationTranslation', 'description')->isAllEscapedData('ApplicationTranslation', 'screenshot')->isAllEscapedData('ApplicationTranslation', 'thumbnail')->isAllEscapedData('ApplicationTranslation', 'author')->isAllEscapedData('ApplicationTranslation', 'author_aboutme')->isAllEscapedData('ApplicationTranslation', 'author_affiliation')->isAllEscapedData('ApplicationTranslation', 'author_photo')->isAllEscapedData('ApplicationTranslation', 'author_quote')->isAllEscapedData('Member', 'name')->end()->post('opOpenSocialPlugin/info/' . $xssApp->id, array('sf_method' => 'put'))->checkCSRF();
$user->info('opOpenSocialPlugin/delete')->get('opOpenSocialPlugin/delete/' . $xssApp->id)->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->end()->post('opOpenSocialPlugin/delete/' . $xssApp->id, array())->checkCSRF();
$user->info('opOpenSocialPlugin/update')->post('opOpenSocialPlugin/update/' . $xssApp->id, array())->checkCSRF();
$user->info('opOpenSocialPlugin/active')->post('opOpenSocialPlugin/active/' . $xssApp->id, array())->checkCSRF();
$user->info('opOpenSocialPlugin/inactivate')->post('opOpenSocialPlugin/inactivate/' . $xssApp->id, array())->checkCSRF();
$xssApp->setIsActive(false);
$xssApp->save();
$user->info('opOpenSocialPlugin/inactiveList')->get('opOpenSocialPlugin/inactiveList')->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->end();
$xssApp->setIsActive(true);
$xssApp->save();
$user->info('opOpenSocialPlugin/updateConsumerSecret')->get('opOpenSocialPlugin/updateConsumerSecret/' . $xssApp->id)->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->end()->post('opOpenSocialPlugin/updateConsumerSecret/' . $xssApp->id, array())->checkCSRF();
$user->info('opOpenSocialPlugin/deleteConsumerSecret')->get('opOpenSocialPlugin/deleteConsumerSecret/' . $xssApp->id)->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->end()->post('opOpenSocialPlugin/deleteConsumerSecret/' . $xssApp->id, array())->checkCSRF();
$connection->rollback();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$user = new opTestFunctional(new opBrowser(), new lime_test(null));
$user->info('1. Testing alien')->info('public_flag: public')->get('/community/2')->info('1-1. Alien cannot access the community home')->with('request')->begin()->isParameter('module', 'community')->isParameter('action', 'home')->end()->with('response')->begin()->isStatusCode(404)->end()->info('public_flag: open')->get('/community/3')->info('1-2. Alien can access the community home')->with('request')->begin()->isParameter('module', 'community')->isParameter('action', 'home')->end()->with('response')->isStatusCode(200);
opCommunityAclBuilder::clearCache();
if (class_exists('opCommunityTopicAclBuilder')) {
    opCommunityTopicAclBuilder::clearCache();
}
$user->login('*****@*****.**', 'password');
$user->info('2. Testing Community Member')->info('public_flag: public')->get('/community/2')->info('2-1. Community Member can access the community home')->with('request')->begin()->isParameter('module', 'community')->isParameter('action', 'home')->end()->with('response')->isStatusCode(200)->info('public_flag: open')->get('/community/3')->info('2-2. Community Member can access the community home')->with('request')->begin()->isParameter('module', 'community')->isParameter('action', 'home')->end()->with('response')->isStatusCode(200);
opCommunityAclBuilder::clearCache();
if (class_exists('opCommunityTopicAclBuilder')) {
    opCommunityTopicAclBuilder::clearCache();
}
$user->login('*****@*****.**', 'password');
$user->info('3. Testing SNS Member')->info('public_flag: public')->get('/community/2')->info('3-1. SNS Member can access the community home')->with('request')->begin()->isParameter('module', 'community')->isParameter('action', 'home')->end()->with('response')->isStatusCode(200)->info('public_flag: open')->get('/community/3')->info('3-2. SNS Member can access the community home')->with('request')->begin()->isParameter('module', 'community')->isParameter('action', 'home')->end()->with('response')->isStatusCode(200);
$user->login('*****@*****.**', 'password');
$user->info('community/search')->get('/community/search')->with('html_escape')->begin()->isAllEscapedData('CommunityCategory', 'name')->isAllEscapedData('Community', 'name')->countEscapedData(1, 'CommunityConfig', 'value', array('width' => 36, 'rows' => 3))->end()->info('/community/edit - CSRF')->post('/community/edit')->checkCSRF()->info('/config/communityTopicNotificationMail/1 - CSRF')->post('/config/communityTopicNotificationMail/1', array('topic_notify' => array()))->followRedirect()->checkCSRF()->info('/community/dropMember/id/1/member_id/2 - CSRF')->post('/community/dropMember/id/1/member_id/2')->checkCSRF()->info('/community/subAdminRequest/id/1/member_id/2 - CSRF')->post('/community/subAdminRequest/id/1/member_id/2', array('admin_request' => array()))->checkCSRF()->info('/community/removeSubAdmin/id/5/member_id/2 - CSRF')->post('/community/removeSubAdmin/id/5/member_id/2')->checkCSRF()->info('/community/changeAdminRequest/id/1/member_id/2 - CSRF')->post('/community/changeAdminRequest/id/1/member_id/2', array('admin_request' => array()))->checkCSRF()->info('community/delete/1 - CSRF')->post('community/delete/1', array('is_delete' => 1))->checkCSRF()->login('*****@*****.**', 'password')->info('/community/quit?id=1 - CSRF')->post('/community/quit?id=1')->checkCSRF()->login('*****@*****.**', 'password')->info('/community/join?id=1 - CSRF')->post('/community/join?id=1', array('community_join' => array()))->checkCSRF()->login('*****@*****.**', 'password')->info('/member/home - XSS')->get('/member/home')->with('html_escape')->begin()->isAllEscapedData('Community', 'name')->end()->info('/community/changeAdminRequest/id/1055/member_id/1056 - XSS')->get('/community/changeAdminRequest/id/1055/member_id/1056')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('Community', 'name')->end()->info('/community/changeAdminRequest/id/1055/member_id/1056 - XSS')->get('/community/changeAdminRequest/id/1055/member_id/1056')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('Community', 'name')->end()->info('/community/dropMember/id/1055/member_id/1056 - XSS')->get('/community/dropMember/id/1055/member_id/1056')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->end()->info('/community/joinlist - XSS')->get('/community/joinlist')->with('html_escape')->begin()->isAllEscapedData('Community', 'name')->end()->info('/community/memberList/id/1055 - XSS')->get('/community/memberList/id/1055')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->end()->info('/community/memberManage/id/1055 - XSS')->get('/community/memberManage/id/1055')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->end()->info('/community/search - XSS')->get('/community/search', array('community' => array('name' => 'Community.name')))->with('html_escape')->begin()->isAllEscapedData('Community', 'name')->countEscapedData(1, 'CommunityConfig', 'value', array('width' => 36))->end()->info('/community/removeSubAdmin/id/1056/member_id/1056 - XSS')->get('/community/removeSubAdmin/id/1056/member_id/1056')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->end()->info('/community/1055 - XSS')->get('/community/1055')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('Community', 'name')->countEscapedData(1, 'CommunityConfig', 'value', array('width' => 36))->end()->login('*****@*****.**', 'password')->info('/community/quit/id/1055 - XSS')->get('/community/quit/id/1055')->with('html_escape')->begin()->isAllEscapedData('Community', 'name')->end()->login('*****@*****.**', 'password')->info('/community/join?id=1055 - XSS')->get('/community/join?id=1055')->with('html_escape')->begin()->isAllEscapedData('Community', 'name')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new opTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color()));
$browser->info('Login')->get('/')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')))->info('/monitoring/editImage - CSRF')->post('/monitoring/editImage')->checkCSRF()->info('/monitoring/deleteImage/id/1 - CSRF')->post('/monitoring/deleteImage/id/1')->checkCSRF()->info('/monitoring/deleteFile/id/3 - CSRF')->post('/monitoring/deleteFile/id/3')->checkCSRF()->info('/monitoring/imageList - XSS')->get('/monitoring/imageList')->with('html_escape')->begin()->isAllEscapedData('File', 'name')->end()->info('/monitoring/deleteImage/id/1055 - XSS')->get('/monitoring/deleteImage/id/1055')->with('html_escape')->begin()->isAllEscapedData('File', 'name')->end()->info('/monitoring/fileList - XSS')->get('/monitoring/fileList')->with('html_escape')->begin()->isAllEscapedData('File', 'name2')->isAllEscapedData('File', 'original_filename')->end()->info('/monitoring/deleteFile/id/1056 - XSS')->get('/monitoring/deleteFile/id/1056')->with('html_escape')->begin()->isAllEscapedData('File', 'name2')->isAllEscapedData('File', 'original_filename')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$test = new opTestFunctional(new sfBrowser());
include dirname(__FILE__) . '/../../bootstrap/database.php';
$test->login('*****@*****.**', 'password');
$test->setCulture('en');
$test->get('/diary')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'index')->end()->with('response')->begin()->checkElement('h3', 'Recently Posted Diaries')->end();
$countPublicSNS = Doctrine::getTable('Diary')->createQuery()->andWhereIn('public_flag', array(DiaryTable::PUBLIC_FLAG_OPEN, DiaryTable::PUBLIC_FLAG_SNS))->count();
$test->info('Pager Test: diary/list')->get('/diary/list')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of ' . $countPublicSNS)->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', true)->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'list')->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 40 of ' . $countPublicSNS)->checkElement('.pagerRelative .prev', true)->checkElement('.pagerRelative .next', true)->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'list')->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'list')->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'list')->isParameter('page', 1)->end();
$test->info('Pager Test: diary/listFriend')->get('/diary/listFriend')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 21')->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', true)->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listFriend')->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 21 of 21')->checkElement('.pagerRelative .prev', true)->checkElement('.pagerRelative .next', false)->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listFriend')->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listFriend')->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listFriend')->isParameter('page', 1)->end();
$test->info('Pager Test: diary/listMember')->get('/diary/listMember/3')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 20')->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', false)->end()->get('/diary/listMember/4')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 31')->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', true)->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 31 of 31')->checkElement('.pagerRelative .prev', true)->checkElement('.pagerRelative .next', false)->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('page', 1)->end()->get('/diary/listMember/4/2009/4')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 26')->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', true)->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 26 of 26')->checkElement('.pagerRelative .prev', true)->checkElement('.pagerRelative .next', false)->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('page', 1)->end()->get('/diary/listMember/4/2009/4/1')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 21')->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', true)->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('day', 1)->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 21 of 21')->checkElement('.pagerRelative .prev', true)->checkElement('.pagerRelative .next', false)->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('day', 1)->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('day', 1)->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('day', 1)->isParameter('page', 1)->end()->get('/diary/listMember/4/2009/6')->with('response')->begin()->checkElement('.pagerRelative', false)->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$test = new opTestFunctional(new sfBrowser());
$test->setMobile();
include dirname(__FILE__) . '/../../bootstrap/database.php';
$test->setCulture('en');
$test->login('*****@*****.**', 'password');
$test->info('AccessBlocked Member Test')->get('/diary/listMember/1/2009/3/1')->isForwardedTo('default', 'error')->get('/diary/listMember/2/2009/3/1')->isForwardedTo('diary', 'listMember')->get('/diary/listMember/1/2009/3')->isForwardedTo('default', 'error')->get('/diary/listMember/2/2009/3')->isForwardedTo('diary', 'listMember')->get('/diary/listMember/1')->isForwardedTo('default', 'error')->get('/diary/listMember/2')->isForwardedTo('diary', 'listMember')->get('/diary/listMember')->isForwardedTo('diary', 'listMember')->get('/diary/1')->isForwardedTo('default', 'error')->get('/diary/2')->isForwardedTo('diary', 'show')->post('/diary/1/comment/create')->isForwardedTo('default', 'error')->post('/diary/2/comment/create')->isForwardedTo('diaryComment', 'create');
Beispiel #20
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$t = new opTestFunctional(new sfBrowser());
include dirname(__FILE__) . '/../../bootstrap/database.php';
$mailAddress = '*****@*****.**';
$myFriendMailAddress = '*****@*****.**';
$notMyFriendMailAddress = 'sns5@example';
$t->login($mailAddress, 'password');
$t->setCulture('en');
$t->info('should be able to post a new diary entry');
$title = 'テストタイトル';
$body = 'テスト本文';
$publicFlag = PluginDiaryTable::PUBLIC_FLAG_SNS;
//全員に公開
$json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'body' => $body, 'public_flag' => $publicFlag))->getResponse()->getContent();
$data = json_decode($json, true);
$t->test()->is($data['status'], 'success', 'should return status code "success"');
$t->test()->ok($data['data']['id'], 'should have id');
$t->test()->ok($data['data']['member'], 'should have member info');
$t->test()->is($data['data']['title'], $title, 'should have the same title posted');
$t->test()->is($data['data']['body'], $body, 'should have the same body posted');
$t->test()->is($data['data']['public_flag'], $publicFlag, 'should have the same publid flag posted');
$t->test()->ok($data['data']['created_at'], 'should have the date posted');
$t->info('should return error when the title is empty');
$json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => '', 'body' => $body, 'public_flag' => $publicFlag))->with('response')->begin()->isStatusCode('400')->end();
$json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'body' => $body, 'public_flag' => $publicFlag))->with('response')->begin()->isStatusCode('400')->end();
$t->info('should return error when the body is empty');
$json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'body' => '', 'public_flag' => $publicFlag))->with('response')->begin()->isStatusCode('400')->end();
$json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'public_flag' => $publicFlag))->with('response')->begin()->isStatusCode('400')->end();
$t->info('should return error when the public flag is empty');
<?php

$app = 'mobile_frontend';
include dirname(__FILE__) . '/../../bootstrap/functional.php';
$member1 = Doctrine::getTable('Member')->findOneByName('A');
$xssMember = Doctrine::getTable('Member')->findOneByName("<&\"'>Member.name ESCAPING HTML TEST DATA");
$xssApp = Doctrine::getTable('Application')->findOneByUrl('http://example.com/dummy4.xml');
$xssMemberApp = Doctrine::getTable('MemberApplication')->findOneByMemberIdAndApplicationId($xssMember->id, $xssApp->id);
$connection = Doctrine::getTable('Application')->getConnection();
$connection->beginTransaction();
$browser = new opBrowser();
$user = new opTestFunctional($browser, new lime_test(14, new lime_output_color()));
$user->setMobile();
$user->info('application/add')->login('*****@*****.**', 'password')->get('application/add/' . $xssApp->id)->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->end()->post('application/add/' . $xssApp->id, array())->checkCSRF();
$user->info('application/gallery')->get('application/gallery')->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->end();
$user->info('application/info')->get('application/info/' . $xssApp->id)->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->isAllEscapedData('ApplicationTranslation', 'description')->isAllEscapedData('ApplicationTranslation', 'thumbnail')->isAllEscapedData('ApplicationTranslation', 'author')->end();
$mid = $xssApp->addToMember($member1);
$user->info('application/invite')->get('application/invite/' . $mid)->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->end()->post('application/invite/' . $mid, array())->checkCSRF();
$user->info('application/list')->login('*****@*****.**', 'password')->get('application/list')->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->end();
$user->info('application/remove')->get('application/remove/' . $xssMemberApp->id)->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->end()->post('application/remove/' . $xssMemberApp->id, array())->checkCSRF();
$user->info('application')->get('application/' . $xssApp->id)->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->end();
$user->info('application/location')->get('application/' . $xssApp->id . '?type=cell')->with('html_escape')->begin()->isAllEscapedData('ApplicationTranslation', 'title')->end();
$connection->rollback();
Beispiel #22
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new opTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color()));
$browser->info('Login')->get('/')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')))->info('/plugin/list/type/application - CSRF')->post('/plugin/list/type/application', array())->followRedirect()->checkCSRF()->info('/plugin/list/type/auth - CSRF')->post('/plugin/list/type/auth', array())->followRedirect()->checkCSRF()->info('/plugin/list/type/skin - CSRF')->post('/plugin/list/type/skin', array())->followRedirect()->checkCSRF();
Beispiel #23
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new opTestFunctional(new sfBrowser(), new lime_test(null, new lime_output_color()));
$params = array('admin_user' => array());
$browser->info('0. Login')->get('/default/login')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')))->isStatusCode(302)->info('1. When an admin user tries to change the SNS configuration. (ref. #3488)')->info('A category is not selected, admin user can change the general configuration.')->get('/sns/config')->click('設定変更')->isStatusCode(302)->info('A general category is selected, admin user can change the general configuration.')->get('/sns/config/category/general')->click('設定変更')->isStatusCode(302)->info('An authentication category is selected, admin user can change the authentication configuration.')->get('/sns/config/category/authentication')->click('設定変更')->isStatusCode(302)->info('A mobile category is selected, admin user can change the mobile configuration.')->get('/sns/config/category/mobile')->click('設定変更')->isStatusCode(302)->info('A policy category is selected, admin user can change the policy configuration.')->get('/sns/config/category/policy')->click('設定変更')->isStatusCode(302)->info('/sns/config - CSRF')->post('/sns/config')->checkCSRF()->info('/sns/config/category/external_login_page - CSRF')->post('/sns/config/category/external_login_page')->checkCSRF()->info('/sns/config/category/authentication - CSRF')->post('/sns/config/category/authentication')->checkCSRF()->info('/sns/config/category/mobile - CSRF')->post('/sns/config/category/mobile')->checkCSRF()->info('/sns/config/category/policy - CSRF')->post('/sns/config/category/policy')->checkCSRF()->info('/sns/config/category/api_keys - CSRF')->post('/sns/config/category/api_keys')->checkCSRF()->info('/sns/term - CSRF')->post('/sns/term')->checkCSRF()->info('/sns/cache - CSRF')->post('/sns/cache')->checkCSRF()->info('/sns/richTextarea - CSRF')->post('/sns/richTextarea')->checkCSRF()->info('/sns/changeRichTextareaButtonOrder - CSRF')->setHttpHeader('X_REQUESTED_WITH', 'XMLHttpRequest')->post('/sns/changeRichTextareaButtonOrder')->checkCSRF();
/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */

$_app = 'mobile_frontend';
include(dirname(__FILE__).'/../../bootstrap/unit.php');
include dirname(__FILE__).'/../../bootstrap/functional.php';
include dirname(__FILE__).'/../../bootstrap/database.php';

$t = new lime_test();
$browser = new opTestFunctional(new opBrowser(), $t);
$browser->setMobile();
$browser->setCulture('en');

$table = Doctrine::getTable('IntroFriend');

$t->info('-- If removed the friend test --');

$t->diag('Before removing friend');
$t->is($table->createQuery()->count(), 6, 'count of intro_friend');
$t->isa_ok($table->find(1), 'IntroFriend', 'introductory of friend is exist(1 > 3)');
$t->isa_ok($table->find(2), 'IntroFriend', 'introductory of friend is exist(3 > 1)');

$browser
  ->info('Login')
  ->login('*****@*****.**', 'password')
<?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */
include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../bootstrap/database.php';
include dirname(__FILE__) . '/../../bootstrap/util.php';
setBlogUrl(1, FEED_URL);
setBlogUrl(2, FEED_URL);
setBlogUrl(3, FEED_URL);
addFriend(1, 2);
addFriend(1, 3);
addFriend(3, 1, true);
Doctrine::getTable('BlogRssCache')->updateByMemberId(1);
Doctrine::getTable('BlogRssCache')->updateByMemberId(2);
Doctrine::getTable('BlogRssCache')->updateByMemberId(3);
$test = new opTestFunctional(new sfBrowser());
$test->login('*****@*****.**', 'password');
$test->setCulture('en');
$test->get('/blog')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'index')->end()->with('response')->begin()->checkElement('h3', 'Newest blog')->end()->get('/blog/user')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'user')->end()->with('response')->begin()->checkElement('h3', 'Newest blog of OpenPNE1')->end()->get('/blog/user/2')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'user')->end()->with('response')->begin()->checkElement('h3', 'Newest blog of OpenPNE2')->end()->get('/blog/user/3')->with('response')->begin()->checkElement('h3', NULL)->end()->get('/blog/friend')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'friend')->end()->with('response')->begin()->checkElement('h3', 'Friends Newest blog')->end();
<?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */

include dirname(__FILE__).'/../../bootstrap/functional.php';
include dirname(__FILE__).'/../../bootstrap/database.php';

$browser = new opTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color()));
$browser
  ->info('Login')
  ->login('*****@*****.**', 'password')
  ->isStatusCode(302)

// CSRF
  ->info('/introfriend/2 - CSRF')
  ->post('/introfriend/2')
  ->checkCSRF()

  ->info('/introfriend/list/friend/delete/3 - CSRF')
  ->post('/introfriend/list/friend/delete/3')
  ->checkCSRF()

  ->info('/introfriend/manage/friend/delete/3 - CSRF')
  ->post('/introfriend/list/friend/delete/3')
  ->checkCSRF()
<?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */
include dirname(__FILE__) . '/../../bootstrap/functional.php';
include dirname(__FILE__) . '/../../bootstrap/database.php';
$browser = new opTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color()));
$browser->setMobile();
$browser->info('Login')->login('*****@*****.**', 'password')->isStatusCode(302)->info('/message/receiveList - CSRF')->post('/message/receiveList')->checkCSRF()->info('/message/sendList - CSRF')->post('/message/sendList')->checkCSRF()->info('/message/draftList - CSRF')->post('/message/draftList')->checkCSRF()->info('/message/dustList - CSRF')->post('/message/dustList')->checkCSRF()->info('/message/sendToFriend/id/1 - CSRF')->post('/message/sendToFriend/id/1')->checkCSRF()->info('/message/reply/id/2 - CSRF')->post('/message/reply/id/2')->checkCSRF()->info('/message/receiveList - XSS')->get('/message/receiveList')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->countEscapedData(1, 'SendMessageData', 'subject', array('width' => 28))->end()->info('/message/sendList - XSS')->get('/message/sendList')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->countEscapedData(1, 'SendMessageData', 'subject', array('width' => 28))->end()->info('/message/draftList - XSS')->get('/message/draftList')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->countEscapedData(1, 'SendMessageData', 'subject', array('width' => 28))->end()->info('/message/dustList - XSS')->get('/message/dustList')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->countEscapedData(1, 'SendMessageData', 'subject', array('width' => 28))->end()->info('/message/read/2 - XSS')->get('/message/read/2')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('SendMessageData', 'subject')->isAllEscapedData('SendMessageData', 'body')->end()->info('/message/check/1 - XSS')->get('/message/check/1')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('SendMessageData', 'subject')->isAllEscapedData('SendMessageData', 'body')->end()->info('/message/checkDelete/3 - XSS')->get('/message/checkDelete/3')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('SendMessageData', 'subject')->isAllEscapedData('SendMessageData', 'body')->end()->info('/message/sendToFriend/id/2 - XSS')->get('/message/sendToFriend/id/2')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->end()->info('/message/reply/id/2 - XSS')->get('/message/reply/id/2')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new sfBrowser();
$user = new opTestFunctional($browser, new lime_test(5, new lime_output_color()));
$user->login('*****@*****.**', 'password');
// CSRF
$user->info('/album/1055/photo/insert - CSRF')->post('/album/1055/photo/insert')->checkCSRF()->info('/album/photo/update/1055 - CSRF')->post('/album/photo/update/1055')->checkCSRF()->info('/album/photo/delete/1055 - CSRF')->post('/album/photo/delete/1055')->checkCSRF()->info('/album/1055/photo/add - XSS')->get('/album/1055/photo/add')->with('html_escape')->begin()->isAllEscapedData('Album', 'title')->end()->info('/album/photo/1055 - XSS')->get('/album/photo/1055')->with('html_escape')->begin()->isAllEscapedData('AlbumImage', 'description')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$test = new opTestFunctional(new sfBrowser());
$test->setMobile();
include dirname(__FILE__) . '/../../bootstrap/database.php';
$test->login('*****@*****.**', 'password');
$test->setCulture('en');
$test->get('/diary/1')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'show')->isParameter('id', 1)->end()->with('response')->begin()->isStatusCode(200)->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new opTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color()));
$browser->info('Login')->login('*****@*****.**', 'password')->info('/confirmation/friend_confirm/2 - CSRF')->post('/confirmation/friend_confirm/2')->checkCSRF()->info('/confirmation/community_confirm/11 - CSRF')->post('/confirmation/community_confirm/11')->checkCSRF()->login('*****@*****.**', 'password')->info('/confirmation/community_admin_request/5 - CSRF')->post('/confirmation/community_admin_request/5')->checkCSRF()->login('*****@*****.**', 'password')->info('/confirmation/community_sub_admin_request/8 - CSRF')->post('/confirmation/community_sub_admin_request/8')->checkCSRF()->login('*****@*****.**', 'password')->info('/confirmation?category=friend_confirm - XSS')->get('/confirmation?category=friend_confirm')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->end()->info('/confirmation?category=community_confirm - XSS')->get('/confirmation?category=community_confirm')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('Community', 'name')->end()->login('*****@*****.**', 'password')->info('/confirmation?category=community_admin_request - XSS')->get('/confirmation?category=community_admin_request')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('Community', 'name')->end()->info('/confirmation?category=community_sub_admin_request - XSS')->get('/confirmation?category=community_sub_admin_request')->with('html_escape')->begin()->isAllEscapedData('Member', 'name')->isAllEscapedData('Community', 'name')->end();