-
-class AtomPubClient
-{
- /**
- *
- * @param string $url collection feed URL
- * @param string $user auth username
- * @param string $pass auth password
- */
- function __construct($url, $user, $pass)
- {
- $this->url = $url;
- $this->user = $user;
- $this->pass = $pass;
- }
-
- /**
- * @param string $baseUrl to attempt feed discovery from
- * @return AtomPubClient
- */
- static function discoverFromPage($baseUrl)
- {
-
- }
-
- function get()
- {
-
- }
-
- function post($stuff, $type='application/atom+xml;type=entry')
- {
- // post it up!
- // optional 'Slug' header too
- // .. receive ..
- if ($response->getStatus() == '201') {
- // yay
- // MUST have a "Location" header
- // if it has a Content-Location header, it MUST match Location
- // and if it does, check the response body -- it should match what we posted, more or less.
- } else {
- throw new Exception("Expected HTTP 201 on POST, got " . $response->getStatus());
- }
- }
-
- function put($data, $type='application/atom+xml;type=entry')
- {
- // PUT it up!
- // must get a 200 back.
- // unlike post, we don't get the location too.
- }
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2010, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
+
+$shortoptions = 'n:p:';
+$longoptions = array('nickname=', 'password=', 'dry-run');
+
+$helptext = <<<END_OF_HELP
+USAGE: atompub_test.php [options]
+
+Runs some tests on the AtomPub interface for the site. You must provide
+a user account to authenticate as; it will be used to make some test
+posts on the site.
+
+Options:
+ -n<user> --nickname=<user> Nickname of account to post as
+ -p<pass> --password=<pass> Password for account
+ --dry-run Skip tests that modify the site (post, delete)
+
+END_OF_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
+
+$user = get_option_value('n', 'nickname');
+$pass = get_option_value('p', 'password');
+
+if (!$user) {
+ die("Must set a user: --nickname=<username>\n");
+}
+if (!$pass) {
+ die("Must set a password: --password=<username>\n");