Files
Gnuboard7/plugins/_bundled/sirsoft-pay_kginicis/tests/Feature/Controllers/MobileCallbackRouteTest.php
T
HeuJung 52ee8c855a chore(release): 공개 소스 본문 내부 단서(· 호칭) 정리
공개 release 발행 시 파일 본문 누출 검사(check-public-release-leakage)에
걸리던 내부 단서를 정리해 발행을 차단하지 않도록 함.

- 코드/테스트 주석·문서 본문의 "" 규정 인용을 "코어 규정/규칙" 등
 중립 표현으로 치환 (코어·이커머스·board·kginicis·gdpr·pay·템플릿 전 영역)
- 내부 역할 호칭 ""/""를 문맥에 맞는 중립 표현으로 일반화
- config/app.php 의 보호경로 목록(G7_UPDATE_PROTECTED_PATHS) 내 파일명은
 기능 코드이므로 삭제 대신 검사기 화이트리스트에 등록

주석/설명 문자열/문서 본문만 변경 — 로직·데이터·동작 무변경.
검증: 누출 재검사 error 0 / warn 0, 영향 테스트 TS 140/140·PHP 113/113 통과.
2026-07-02 17:58:33 +09:00

92 lines
3.9 KiB
PHP

<?php
namespace Plugins\Sirsoft\PayKginicis\Tests\Feature\Controllers;
use Plugins\Sirsoft\PayKginicis\Tests\PluginTestCase;
class MobileCallbackRouteTest extends PluginTestCase
{
/**
* KG 이니시스 모바일 표준결제는 P_NEXT_URL 로 POST 콜백을 보낸다.
* 라우트가 GET 만 허용하면 405 Method Not Allowed 회귀가 발생한다.
* 가상계좌 결제 시 운영 검증으로 발견된 회귀.
*/
public function test_mobile_callback_route_accepts_post(): void
{
$response = $this->withoutMiddleware()->post(
'/plugins/sirsoft-pay_kginicis/payment/mobile/callback',
[
'P_STATUS' => '99',
'P_RMESG1' => 'test',
'P_OID' => 'TEST-OID-NOT-EXIST',
'P_TID' => 'TEST-TID',
'P_REQ_URL' => 'https://stgstdpay.inicis.com/api/payAuth',
'P_AMT' => '1000',
'idc_name' => 'fc',
]
);
$this->assertNotSame(405, $response->getStatusCode(), 'POST callback must not return 405 Method Not Allowed');
}
public function test_mobile_callback_route_accepts_get(): void
{
$response = $this->withoutMiddleware()->get(
'/plugins/sirsoft-pay_kginicis/payment/mobile/callback?P_STATUS=99&P_OID=TEST-OID-NOT-EXIST'
);
$this->assertNotSame(405, $response->getStatusCode(), 'GET callback should remain supported');
}
/**
* 사용자 취소 시 KG 이니시스가 P_STATUS=01 + P_RMESG1='사용자가 결제를 취소하셨습니다.' 를 보낸다.
* 이 경우 오류 모달을 띄우지 않고 체크아웃으로 조용히 복귀해야 한다.
* Playwright 운영 재현으로 확인된 패턴.
*/
public function test_mobile_callback_user_cancel_returns_to_checkout_without_error(): void
{
$response = $this->withoutMiddleware()->post(
'/plugins/sirsoft-pay_kginicis/payment/mobile/callback?orderId=TEST-CANCEL',
[
'P_STATUS' => '01',
'P_RMESG1' => '사용자가 결제를 취소하셨습니다.',
'P_OID' => 'TEST-CANCEL',
'P_TID' => '',
'P_REQ_URL' => 'https://fcmobile.inicis.com/smart/payReq.ini',
'P_AMT' => '1000',
'idc_name' => 'fc',
]
);
$this->assertSame(302, $response->getStatusCode());
$location = $response->headers->get('Location');
$this->assertStringContainsString('/shop/checkout', $location);
$this->assertStringNotContainsString('error=', $location, '사용자 취소는 error 쿼리 미부착으로 모달 미노출');
$this->assertStringNotContainsString('message=', $location, '사용자 취소는 message 쿼리 미부착');
}
/**
* 사용자 취소 외 일반 실패 (예: MX1006) 는 종전대로 error/message 쿼리 부착하여 모달 노출.
*/
public function test_mobile_callback_general_failure_preserves_error_query(): void
{
$response = $this->withoutMiddleware()->post(
'/plugins/sirsoft-pay_kginicis/payment/mobile/callback?orderId=TEST-FAIL',
[
'P_STATUS' => '01',
'P_RMESG1' => '일시적으로 오류로 결제시도가 정상적으로 처리되지 않았습니다.(MX1006)',
'P_OID' => 'TEST-FAIL',
'P_TID' => '',
'P_REQ_URL' => 'https://fcmobile.inicis.com/smart/payReq.ini',
'P_AMT' => '1000',
'idc_name' => 'fc',
]
);
$this->assertSame(302, $response->getStatusCode());
$location = $response->headers->get('Location');
$this->assertStringContainsString('error=', $location);
$this->assertStringContainsString('MX1006', $location);
}
}