Does this module work with `codeception/module-rest`?
まだ誰も着手していません。
評価
調査の方向性
tests/Codeception/Acceptance/FetchCest.php と Acceptance.suite.yml から始め、次に PhpBrowser 下の REST モジュール設定と Mezzio 設定を比較します。Mezzio モジュールを使用して認証済み POST リクエストを再現し、関係するモジュールと REST 統合を調査します。Mezzio でリクエストの認証が正常に成功し、この動作をカバーする回帰テストがあれば完了です。
索引モデルが issue の本文から書いたものです。
説明
I'm getting 401 (Unauthorized) in the tests I use $I->amHttpAuthenticated('test', 'test'); with.
Routes that I don't check authorization seem to work.
When I run a test using Mezzio
FetchCest: Test fetch and retrieve svg
Signature: Codeception\Acceptance\FetchCest:testFetchAndRetrieveSvg
Test: tests/Codeception/Acceptance/FetchCest.php:testFetchAndRetrieveSvg
Scenario --
I am http authenticated "test","test"
I send post "/fetch",{"url":"https://upload.wikimedia.org/wikipedia/en/8/80/Wikipedia-logo-v2.svg","name":"Wikipedia Logo"}
[Request] POST /fetch {"url":"https://upload.wikimedia.org/wikipedia/en/8/80/Wikipedia-logo-v2.svg","name":"Wikipedia Logo"}
[Request Headers] []
[Page] /fetch
[Response] 401
[Request Cookies] []
[Response Headers] {"WWW-Authenticate":["Basic realm="media-store""]}
[Response]
I see response is json
FAIL
When I run it using PhpBrowser
FetchCest: Test fetch and retrieve svg
Signature: Codeception\Acceptance\FetchCest:testFetchAndRetrieveSvg
Test: tests/Codeception/Acceptance/FetchCest.php:testFetchAndRetrieveSvg
Scenario --
I am http authenticated "test","test"
I send post "/fetch",{"url":"https://upload.wikimedia.org/wikipedia/en/8/80/Wikipedia-logo-v2.svg","name":"Wikipedia Logo"}
[Request] POST http://media-store.localhost/fetch {"url":"https://upload.wikimedia.org/wikipedia/en/8/80/Wikipedia-logo-v2.svg","name":"Wikipedia Logo"}
[Request Headers] []
[Page] http://media-store.localhost/fetch
[Response] 200
[Request Cookies] []
[Response Headers] {"Server":["nginx/1.27.1"],"Date":["Wed, 09 Oct 2024 02:29:39 GMT"],"Content-Type":["application/json"],"Transfer-Encoding":["chunked"],"Connection":["keep-alive"],"X-Powered-By":["PHP/8.3.12"]}
[Response] {"success":true,"url":"http://media-store.localhost/img/store/79/bd/bb953537891b27c9d26a0f1815584fbe5364/wikipedia-logo","meta":{"width":103,"height":94,"filesize":165428,"mimetype":"image/svg+xml"}}
I see response is json
I see response contains json {"success":true,"meta":{"mimetype":"image/svg+xml"}}
I see response code is 200
I grab data from response by json path "url"
I assert not null "/img/store/79/bd/bb953537891b27c9d26a0f1815584fbe5364/wikipedia-logo"
I assert string contains string ignoring case "Wikipedia","/img/store/79/bd/bb953537891b27c9d26a0f1815584fbe5364/wikipedia-logo"
I assert string contains string ignoring case "Logo","/img/store/79/bd/bb953537891b27c9d26a0f1815584fbe5364/wikipedia-logo"
I am http authenticated "",""
I send get "/img/store/79/bd/bb953537891b27c9d26a0f1815584fbe5364/wikipedia-logo"
[Request] GET http://media-store.localhost/img/store/79/bd/bb953537891b27c9d26a0f1815584fbe5364/wikipedia-logo
[Request Headers] []
[Page] http://media-store.localhost/img/store/79/bd/bb953537891b27c9d26a0f1815584fbe5364/wikipedia-logo
[Response] 200
[Request Cookies] []
[Response Headers] {"Server":["nginx/1.27.1"],"Date":["Wed, 09 Oct 2024 02:29:40 GMT"],"Content-Type":["image/svg+xml"],"Transfer-Encoding":["chunked"],"Connection":["keep-alive"],"X-Powered-By":["PHP/8.3.12"],"Last-Modified":["Tue, 08 Oct 2024 07:59:10 GMT"],"Cache-Control":["public, max-age=86400, no-transform"],"ETag":["0df5066882793e7b1893e3adc393abbc"]}
[Response] <A very long XML string here>
I see response code is 200
PASSED
Here's my Acceptance.suite.yml
actor: AcceptanceTester
suite_namespace: Codeception\Acceptance
modules:
enabled:
- \Codeception\Module\Asserts
- \Codeception\Module\REST
config:
\Codeception\Module\REST:
depends: \Codeception\Module\PhpBrowser
url: http://media-store.localhost/
env:
mezzio:
modules:
enabled:
- \Codeception\Module\Mezzio
config:
\Codeception\Module\REST:
depends: \Codeception\Module\Mezzio
url: /
docker:
modules:
config:
\Codeception\Module\REST:
url: http://localhost:8080/
And my test
public function testFetchAndRetrieveSvg(AcceptanceTester $I): void
{
// Fetch the Wikipedia logo
$I->amHttpAuthenticated('test', 'test');
$I->sendPost('/fetch', [
'url' => 'https://upload.wikimedia.org/wikipedia/en/8/80/Wikipedia-logo-v2.svg',
'name' => 'Wikipedia Logo',
]);
$I->seeResponseIsJson();
$I->seeResponseContainsJson([
'success' => true,
'meta' => [
'mimetype' => 'image/svg+xml',
],
]);
$I->seeResponseCodeIs(StatusCodes::STATUS_OK);
// Parse the URL that we retrieved in the response
$path = parse_url($I->grabDataFromResponseByJsonPath('url')[0])['path'];
$I->assertNotNull($path);
$I->assertStringContainsStringIgnoringCase('Wikipedia', $path);
$I->assertStringContainsStringIgnoringCase('Logo', $path);
// Retrieve the stored image without authentication
$I->amHttpAuthenticated('', '');
$I->sendGet($path);
$I->seeResponseCodeIs(StatusCodes::STATUS_OK);
}
- 主要言語
- PHP
- スター
- 1
- フォーク
- 4
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Codeception/module-mezzio のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
Codeception/module-mezzio#4 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
Codeception/module-mezzio#7 · コメント 4 件 ·
Codeception/module-mezzio の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
taskforcesh/bullmq#5238 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects it対応中かも @bfs2021 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Automattic/jetpack#55517 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
-
area/import type/enhancement when/later
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信