본문 바로가기
MegazoneCloud
← 전체 글
AWS

AWS Transform custom으로 Classic ASP를 ASP.NET Core 10으로 전환하는 실전 가이드 (TD 작성부터 코드 매핑까지)

원본 분석부터 TDD 기반 코드 변환, 통합 리팩토링, 로컬 실행 검증까지

레거시 코드를 AI 에이전트에게 통째로 맡기면 어떻게 될까요? 원본 분석부터 코드 변환, 공통 구조 정리, 실행 검증까지 한꺼번에 진행하면 문제가 생겼을 때 어느 단계부터 다시 확인해야 할지 판단하기 어렵습니다. 그래서 작업을 나누고, 각 단계에서 무엇을 확인해야 다음 단계로 넘어갈 수 있는지 정합니다.

이 글에서는 AWS Transform으로 Classic ASP 전환을 단계별로 실행하고 검증하는 방법을 살펴봅니다. 먼저 AWS Transform continuous modernization으로 원본 저장소를 분석해 전환 범위와 보존할 동작을 정하고, .NET 10 스켈레톤과 입력별 기대값을 준비합니다. AWS Transform custom에서는 각 작업의 범위와 통과 기준을 변환 정의에 담아 기능별 코드 변환과 통합 리팩토링을 따로 실행합니다. 통합을 마친 뒤에는 변환 단계에서 작성한 테스트를 다시 실행하고, 로컬 HTTP 응답과 브라우저에 표시된 두 화면을 확인합니다.

이번 예제에 사용한 원본 코드는 GitHub의 Classic ASP CMS 저장소에서 확인할 수 있습니다.

예제의 범위와 결과는 다음과 같습니다.

항목이번 예제
대상MIT 라이선스로 공개된 Classic ASP CMS의 홈과 관리자 로그인 두 화면
목표ASP.NET Core 10 Razor Pages
데이터원본 DB 대신 정제한 JSON 사본
실행원본 분석 1회, 변환 및 통합 Draft TD 각 1회
검증자동 테스트 63개, 로컬 Kestrel HTTP 검사 22개, 헤드리스 Chrome 렌더링
범위 밖실제 DB 연결, 원본 IIS와의 비교, 운영 배포와 보안 설정, 기대값에 대한 사람의 승인

CMS 전체가 아닌 첫 기능 묶음을 어떻게 잘라 맡기고 무엇으로 확인할지 보여주는 예제입니다.

AWS Transform은 AI 에이전트로 애플리케이션과 인프라의 현대화를 지원하는 서비스입니다. .NET, 메인프레임, VMware 같은 워크로드별 기능과 함께, 프로젝트 요구사항에 맞춰 변환을 직접 정의하는 AWS Transform custom(이하 ATX)을 제공합니다.[1]

ATX에서는 변환 규칙과 작업 범위, 단계별 검증 기준을 Transformation Definition(이하 TD)에 담아 atx CLI로 실행합니다. TD는 이름과 버전이 있는 정의로 저장되므로 같은 지침을 다시 실행하거나 팀에 게시할 수 있습니다.[2]

AWS가 미리 준비한 Managed TD도 있지만, 이번에 확인한 목록에는 Classic ASP(VBScript)를 ASP.NET Core 10 Razor Pages로 옮기는 정의가 없어 Custom TD를 직접 작성했습니다.[3]

전체 흐름은 다음과 같습니다. 분석 결과에서 보존할 동작을 고른 뒤, 변환과 통합을 각각 실행하고 단계마다 어떤 코드와 검증 기록을 확인할지 살펴보겠습니다.

원본 ASP와 변환 기준에서 AWS Transform을 거쳐 로컬 Razor Pages 앱과 테스트로 이어지는 흐름

실선은 전환 흐름입니다. 점선은 사용자가 맡기기 전에 범위와 기대값을, 받은 뒤에 테스트와 화면을 확인해야 하는 지점입니다.

1. 분석부터 실행 검증까지의 단계와 통과 기준 정하기

ATX에 첫 작업을 맡기기 전에 단계를 나누고, 각 단계의 통과 기준을 다음 작업을 시작하는 데 필요한 결과로 정했습니다.

단계주요 작업다음 단계로 넘어갈 기준
분석소스와 의존성을 확인하고 변환 범위 결정이번에 옮길 화면과 제외할 범위, 보존할 동작의 근거 파일 확정
기본 코드 준비스켈레톤과 기대값, 검증 도구 준비스켈레톤 빌드 성공, 보호할 입력 확정
기능별 코드 변환서버 로직과 화면 코드를 나누고 테스트를 먼저 작성빌드, 원본 동작을 확인하는 자동 테스트와 로컬 HTTP 검사 통과
통합과 리팩토링화면 사이의 중복과 뒤섞인 의존성 정리같은 테스트와 HTTP 검사 통과, 테스트 파일 유지와 변경 근거 기록
실행 검증통합 TD가 끝난 뒤 앱을 다시 실행하고 브라우저 화면 확인미리 정한 필수 시나리오 통과, 확인한 범위와 미검증 항목 명시

실행 검증에서 확인할 필수 시나리오도 변환 전에 적어 둡니다. 예를 들어 “익명 사용자가 홈에 접속하면 관리자 링크가 없고, 관리자 권한의 테스트 계정으로 로그인한 뒤 홈에 다시 접속하면 관리자 링크가 보인다”입니다.

2. 원본 저장소를 분석하고 변환 기준 정하기

Classic ASP를 ASP.NET Core 10으로 옮기기 전에 데이터 접근과 인증이 어느 파일에 걸쳐 있는지 확인합니다. AWS Transform continuous modernization에서 선택한 분석 유형은 앱과 데이터, 인프라, 보안 및 운영의 전환 준비 상태를 살펴보는 modernization-readiness입니다.[4]

분석 대상은 MIT 라이선스로 공개된 Classic ASP CMS의 e16829f 커밋입니다.[5] 분석용 Git 저장소에는 앱의 ASP, include, 문서 등 원본 파일 193개와 분석 지침 파일 1개를 넣었습니다. 이미지, CSS, JS, MDB는 분석 입력에서 제외했습니다. 원본 테스트 32개도 뺐습니다. 기대값을 원본 코드의 분기에서 직접 정리하기 위해서입니다. 이번에 변환할 기능은 홈과 관리자 로그인 두 화면입니다.

원본 사본을 등록하고 분석하기

Node.js 22 이상과 atx CLI, AWS 인증 및 필요한 IAM 권한을 준비합니다.[6] 아래 터미널 예시에서 Source 이름은 asp-cms-guide로 줄였습니다. source add의 --path에는 분석용 저장소 legacy-cms/가 들어 있는 상위 폴더를 지정합니다.[7]

$ export AWS_REGION=ap-northeast-2
$ atx ct source add --name asp-cms-guide \
    --provider local --path /work/analysis-input
Source "asp-cms-guide" added (local, asp-cms-guide)

등록한 위치에서 discovery scan으로 Git 저장소를 찾습니다. 응답의 저장소 이름 asp-cms-guide::legacy-cms를 다음 분석 명령에 그대로 넣습니다.

$ atx ct discovery scan --source asp-cms-guide --repo legacy-cms --json
{
  "status": "completed",
  "repos_discovered": 1,
  "repos_skipped": 0,
  "repos": [
    {
      "name": "asp-cms-guide::legacy-cms",
      "source": "asp-cms-guide"
    }
  ],
  "warnings": []
}

--context에는 목표 런타임과 전환 목적을 적습니다. 아래는 지침과 출력을 줄인 예입니다.

$ atx ct analysis run --type modernization-readiness \
    --source asp-cms-guide \
    --repo asp-cms-guide::legacy-cms \
    --context "Assess this original Classic ASP/VBScript CMS for a planned migration to ASP.NET Core 10 Razor Pages." \
    --json
Cloning asp-cms-guide::legacy-cms for modernization assessment...
Analyzing legacy-cms with AWS/modernization-readiness-analysis...
...
{
  "analysisId": "01M88S7E5QDVBJ0KXWMM40JCV9",
  "total": 1,
  "status": "complete",
  "findingCount": 30
}

완료 응답에서 받은 analysisId로 분석 요약과 개선 항목을 저장합니다. 다음 명령을 사용할 때는 예시의 ID를 자신의 분석 ID로 바꾸세요.

$ mkdir -p records/analysis
$ atx ct analysis get --id 01M88S7E5QDVBJ0KXWMM40JCV9 --json \
    > records/analysis/analysis.json
$ atx ct findings list --analysis-id 01M88S7E5QDVBJ0KXWMM40JCV9 --json \
    > records/analysis/findings.json

진행 중인 분석은 atx ct analysis list --status running --json에서 찾을 수 있습니다.[8]

개선 권고에서 보존할 동작 찾기

이 분석용 소스 사본에서 개선 후보 30건(high 9건, medium 20건, low 1건)과 전환 준비 상태 점수 1.41/4를 얻었습니다. 두 화면의 범위를 정할 때는 findings.json의 근거 파일과 권고를 원본 코드와 대조했습니다.

분석 항목이번 예제에 참고한 권고원본에서 확인한 변환 기준
SEC-Q3 인증Referer 검사와 기존 사용자 정보 쿠키를 CSRF 토큰 검증과 프레임워크 쿠키 인증으로 전환신규 로그인에서 암호를 먼저 검사하고, 비활성 계정의 입력별 오류를 보존
DATA-Q2 데이터 접근흩어진 조회를 모으고 원본의 데이터 선택 기준을 테스트홈 후보 중 가장 작은 PageID, 같은 페이지에서 가장 큰 ContentID의 본문 선택. 수정 날짜는 정렬에서 제외

SEC-Q3의 권고에는 “antiforgery token instead of the Referer check”가 나옵니다. 요청 검증과 쿠키 발급 방식을 바꾸려면 어느 시점에 로그인 성공으로 판단하는지도 알아야 합니다. 원본 public/admin/login.asp는 user.login(uid, pass)가 성공해야 세션과 쿠키를 처리합니다. class.user.asp에서 기존 로그인 세션이 없는 경우의 분기를 따라가면, 계정을 조회한 뒤 암호를 먼저 비교하고 암호가 맞을 때만 Disabled를 검사합니다.

검사 순서를 뒤집으면 비활성 계정에 틀린 암호를 넣어도 계정 만료 메시지가 나옵니다. 그래서 요청 검증과 쿠키 처리는 바꾸고, 같은 입력에 돌려주는 오류는 보존하기로 했습니다. records/oracle.md의 AUTH-01에는 비활성 계정의 암호가 틀리면 BadPassword, 맞으면 LoginExpired라고 적었습니다. 변환 TD의 지침은 Check the password before Disabled.입니다.

3. 스켈레톤과 TD 설계하기

미리 만든 .NET 10 스켈레톤을 두 화면의 공통 출발점으로 사용합니다. 원본 ASP 한 파일에 섞여 있던 코드를 나눠 PageModel에서 요청을 받고 Razor에서 HTML을 그립니다.[9] 데이터 선택과 로그인 판단은 서비스로 옮깁니다.

스켈레톤은 Razor Pages와 /healthz 상태 확인만 등록한 빈 프로젝트입니다. 프로젝트 파일과 Program.cs, 폴더 구조를 먼저 고정해 두면 에이전트가 공통 구조를 새로 만들지 않고, 변환 결과가 들어갈 위치도 TD에서 지정할 수 있습니다. reference/의 JSON은 원본 DB를 대신하는 로컬 백엔드이며, 원본의 평문 암호는 제거하고 PBKDF2 해시를 넣어 두었습니다.

example/
  original/                    # 보존할 ASP 원본
  reference/                   # 로컬 백엔드에 사용할 JSON 사본
  dotnet/                      # 스켈레톤: Pages/, Services/, wwwroot/
  td/                          # asp-cms-port/, asp-cms-integration/
  tests/                       # 변환 TD가 작성할 테스트
  tools/                       # 미리 준비한 검증 도구
  records/                     # 분석과 요구사항, 기대값, 실행 기록

로그인을 예로 들면, Transform이 찾은 보안 권고는 findings.json에 있고 원본에서 보존하기로 한 실패 조건은 oracle.md에 있습니다. 변환 후에는 two-screen-mapping.md에서 해당 조건에 연결된 코드와 테스트를 찾습니다. 이때 사용자가 확인할 것은 테스트가 통과했는지와 함께, 비활성 계정에 틀린 암호를 넣었을 때의 오류가 원본과 일치하는지입니다.

TD마다 필수 파일 SKILL.md에 이름과 설명, 작업 지침을 적고 상세 규칙은 references/에 둡니다.[10] 아래 두 TD의 이름과 폴더 구성은 이 예제에서 정했습니다.

  • 역할을 나눕니다. 변환 TD인 asp-cms-port는 홈과 로그인 코드, 원본 대응표, 테스트 결과를 남깁니다. 통합 TD인 asp-cms-integration은 그 코드를 받아 두 화면에 걸친 중복을 정리합니다. 변환과 정리를 한 실행에 섞지 않으면 통합 단계의 diff를 동작은 그대로 두고 구조만 바꾼 변경으로 따로 검토할 수 있습니다.
  • 기준이 되는 파일을 보호합니다. 원본과 JSON 입력, 미리 작성한 기대값과 검증 도구를 보호합니다. Red에서 작성한 테스트 파일은 해시를 남겨 구현과 통합 과정에서 달라졌는지 확인합니다.
  • Red 다음에 Green을 확인합니다. 변환 TD는 테스트가 컴파일된 뒤 Assert에서 실패한 기록을 남기고 기능을 구현합니다. 같은 테스트가 기대값 변경 없이 통과해야 통합 단계로 넘어갑니다.

실행 전에는 어느 입력에 어떤 결과를 기대하는지 정합니다. records/assessment.md에는 분석 근거, records/requirements.md에는 범위와 실행 조건, records/oracle.md에는 원본 위치와 입력별 기대 결과를 적습니다. 변환 TD는 이 자료와 references/two-screen-rules.md를 읽고 테스트 코드를 작성합니다.

실제로 실행한 변환 TD의 SKILL.md 전문 보기

---
name: asp-cms-port
description: Convert only the public Classic ASP CMS home and admin login into the supplied ASP.NET Core 10 Razor Pages skeleton, following the fresh assessment and frozen source oracle with real Red and unchanged-test Green evidence.
---

# Convert two screens

Read AGENTS.md, records/assessment.md, records/requirements.md, records/oracle.md and references/two-screen-rules.md. Work only in this repository.

## Scope and common rules

- Convert only public/default.asp, public/admin/login.asp and required shared dependencies. No additional business screens, databases or infrastructure.
- Preserve original/, reference/, records/oracle.md and supplied tools. Do not read original tests, MDB contents, previous conversions, other projects, user home or credentials.
- Do not inspect image, CSS or JS contents. Copy them unchanged with python3 tools/sync_assets.py and keep their paths.
- Separate data and login decisions in services from Razor rendering and HTTP handling. Use framework cookie authentication, Data Protection and antiforgery.
- Check the password before Disabled. RememberMe remembers a username without authenticating it. Preserve the debug-mode success message and Continue link with HTTP 200. Record intentional security differences.
- Never log password, hash, key or authentication-cookie values. Do not alter an expected result or verification tool to force a pass.

## Work in order

1. Read the relevant operating ASP. Write records/two-screen-mapping.md with source files/lines, oracle IDs, destination code, expected behavior and deliberate differences.
2. Create tests/GuideCms.Tests.csproj referencing dotnet/WebSkeleton.csproj. Available packages include xunit 2.9.3, xunit.runner.visualstudio 3.1.4, Microsoft.NET.Test.Sdk 17.14.1. Use fresh independent test data. Cover every applicable oracle rule without reading old tests.
3. Add minimal compiling stubs and run the tests before implementation. Save records/test-results/red.log and red.trx. Assertions must actually fail; a compiler/discovery/environment error is not Red. Save the stub .cs files in records/red-stubs/ and test-file hashes in records/red-test-files.json before changing production behavior. Explain tests that already pass in Red by their actual stub or helper behavior.
4. Implement only the two screens and necessary services to satisfy the frozen oracle. Run the same unchanged tests, saving green.log and green.trx. Report exact results and any failed implementation attempt. Leave cross-service cleanup to the separate integration TD.
5. Run Release build, all tests, python3 tools/verify_source.py and unchanged-asset hash checks. Write records/port-result.md with source mapping, Red/Green results including Red-pass explanations, initial failures/corrections, intentional differences and limits. Update records/tasks.md and README run instructions.

## Stop

Stop after two-screen conversion, real Red, unchanged-test Green and input/asset preservation. Do not execute the integration workflow or claim real database or live-original verification. An external controller will review tests against the frozen oracle before the integration TD runs.

실제로 실행한 통합 TD의 SKILL.md 전문 보기

---
name: asp-cms-integration
description: Review and refactor the existing two-screen port while preserving its source oracle, pre-existing tests and verification tools, then verify Release, source and asset integrity and actual local HTTP behavior.
---

# Integrate and verify the two-screen port

Read AGENTS.md, records/requirements.md, records/oracle.md, records/two-screen-mapping.md, records/port-result.md, records/oracle-review.md and references/two-screen-rules.md. Require passing Green and the external automated oracle review. If either is absent, record the missing prerequisite and stop.

## Scope and common rules

- Keep only home and login. No added business screens, cloud resources or real database connections.
- Preserve original/, reference/, records/oracle.md, all existing test files and supplied verification tools. Do not change expectations to obtain a pass or restart Red.
- Do not read original tests, MDB contents, old conversions, other projects, user home or credentials. Do not inspect image, CSS or JS contents; assets remain byte-identical.
- Preserve password-before-Disabled, username memory without authentication, debug-mode HTTP 200 success view, legacy route aliases and deliberate security changes. Never log secrets.

## Work in order

1. Run the existing tests and inspect generated code. Record concrete duplication, temporary implementations or confused responsibilities in records/integration-result.md. Choose a small useful refactor. If none is justified, document no-change rather than inventing an abstraction.
2. Refactor implementation while keeping observable behavior, existing tests, tools and oracle unchanged. Run the same tests and save before/after logs and TRX under records/test-results/.
3. Run bash tools/verify.sh. It builds Release, runs tests, verifies original hashes, starts the real local app with test data and checks HTTP behavior. Fix implementation defects if needed, record the first failure and correction, and do not weaken checks.
4. Check every copied asset against records/static-assets.json and original/. Record exact counts, the actual before/after code diff or justified no-change, protected-file integrity and remaining limits. Update records/tasks.md and README.

## Completion

The same pre-existing tests pass, Release builds, HTTP checks pass, original inputs and copied assets are unchanged and no additional business screen exists. Local JSON and source-derived checks do not prove live IIS behavior, real DB integration, production security or deployment readiness.

4. 변환 TD를 실행하고 TDD 결과 검토하기

실행 환경은 atx CLI 3.25.0과 .NET SDK 10.0.402였습니다. 원본과 스켈레톤, TD 및 기대값을 Git에 커밋한 뒤, 예제의 최상위 폴더에서 두 TD를 각각 Draft로 저장합니다. --sd는 지침이 있는 폴더입니다.

$ atx custom def save-draft -n asp-cms-port \
    --description "Public CMS two-screen port after fresh source assessment and frozen oracle" \
    --sd td/asp-cms-port --category remediation --json
{
  "name": "asp-cms-port",
  "version": "3hat9n1vpezi6aaafs1bjyfs",
  "expiresAt": "2026-12-25T07:34:59.277Z"
}
$ atx custom def save-draft -n asp-cms-integration \
    --description "Integrate public CMS two-screen port with protected oracle, tests and independent verification" \
    --sd td/asp-cms-integration --category remediation --json
{
  "name": "asp-cms-integration",
  "version": "3hat9ov7fn6m6nsjag7ypxht",
  "expiresAt": "2026-12-25T07:35:14.759Z"
}

Draft는 30일 뒤 만료됩니다. 실행에는 저장할 때 반환된 이름과 version을 사용하세요. 아래 실행 예시의 -p .은 현재 작업 폴더, -x는 비대화형 실행, -t는 도구 실행 자동 승인, -d는 학습 추출 제외 옵션입니다.[11] --classic을 지정하면 줄 단위 로그를 볼 수 있습니다.

$ atx custom def exec -n asp-cms-port \
    --tv 3hat9n1vpezi6aaafs1bjyfs -p . -x -t -d --classic

실행이 끝나면 records/two-screen-mapping.md부터 엽니다. 여기에는 에이전트가 원본의 각 분기를 어느 코드로 옮겼고 어떤 기대값으로 검사했는지가 담겨 있습니다. 두 화면의 핵심 열을 발췌했습니다.

| 원본 | 기대값 | 변환 위치 |
| --- | --- | --- |
| public/default.asp, class.page.asp | HOME-01/02: PageID와 ContentID 순서 | Pages/Index, Services/HomePageService |
| public/admin/login.asp, class.user.asp | AUTH-01: 암호 다음 Disabled 검사 | Pages/Admin/Login, Services/LoginService |

로그인 테스트가 실패한 이유 확인하기

변환 TD는 테스트 주도 개발(TDD) 순서에 따라 테스트를 먼저 작성하고, 컴파일할 수 있는 최소 구현(Stub)을 대상으로 실행합니다. 2장에서 정한 AUTH-01을 옮긴 테스트는 비활성 계정에 틀린 암호를 넣고 실패 사유까지 확인합니다.

[Fact]
public void Auth01_DisabledAccountWithWrongPasswordIsBadPassword()
{
    var result = CreateService().Login("disabled-admin", "not-the-password");

    Assert.Equal(LoginStatus.BadPassword, result.Status);
    Assert.False(result.Succeeded);
}

Stub은 모든 로그인 요청에 InvalidUser를 반환했습니다. 비활성 계정에 틀린 암호를 넣자 테스트가 기대한 BadPassword와 값이 달라 Assert에서 실패했습니다.

$ dotnet test tests/GuideCms.Tests.csproj -c Release \
    --logger 'trx;LogFileName=red.trx' --results-directory records/test-results
...
실패 GuideCms.Tests.LoginServiceTests.Auth01_DisabledAccountWithWrongPasswordIsBadPassword
오류 메시지:
Assert.Equal() Failure: Values differ
Expected: BadPassword
Actual:   InvalidUser
...
실패!  - 실패:    39, 통과:    24, 건너뜀:     0, 전체:    63 - GuideCms.Tests.dll (net10.0)

63개 중 24개는 이 시점에도 통과했습니다. Stub의 기본 반환값(null, false, InvalidUser)과 스켈레톤의 기존 응답이 부정 조건 테스트의 기대값과 같았기 때문입니다.

원본 분기를 옮기고 같은 테스트로 Green 확인하기

기존 세션 없이 로그인할 때 class.user.asp는 암호가 틀렸는지 확인한 뒤 비활성 계정을 검사합니다. 디버그 출력과 성공 처리를 생략하면 다음 분기가 남습니다.

if rs("Password") <> password then
    addError globals("BAD_PASSWORD")
elseif rs("Disabled") then
    addError globals("LOGIN_EXPIRED")
else
    ' 로그인 성공 처리 생략
end if

변환한 Services/LoginService.cs는 이 순서를 유지하고 평문 비교를 해시 검증으로 바꿨습니다. 사용자를 찾은 뒤의 실제 코드입니다.

if (!PasswordHashVerifier.Verify(password, CmsDataStore.Text(user, "PasswordHash")))
{
    return Failure(LoginStatus.BadPassword, userId);
}
if (CmsDataStore.Flag(user, "Disabled"))
{
    return Failure(LoginStatus.LoginExpired, userId);
}

서비스의 판단과 HTTP 처리는 분리했습니다. LoginModel은 폼 값을 서비스에 넘기고, 성공한 결과로 프레임워크 인증 쿠키를 만듭니다.[12] 아래는 해당 핸들러의 일부이며 오류와 성공 메시지 구성은 생략했습니다.

var result = logins.Login(UserId, Password);
Password = null;
if (!result.Succeeded)
{
    // 오류 메시지 구성은 생략한다.
    return;
}
UpdateRememberedUser(result.UserId, !string.IsNullOrEmpty(RememberMe));
var principal = AdminAccess.CreatePrincipal(result, CookieAuthenticationDefaults.AuthenticationScheme);
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);
HttpContext.User = principal;
LoggedIn = true;

전환한 로그인 폼은 이미 인증된 사용자가 다시 제출해도 암호를 확인합니다. 홈의 관리자 링크는 인증된 사용자의 역할 값이 50 이상일 때 표시합니다.

같은 테스트 파일로 다시 실행한 Green 기록입니다. 앞서 실패한 암호 오류 사례와, 같은 비활성 계정에 올바른 암호를 넣으면 LoginExpired가 되는 사례가 모두 통과했습니다.

$ dotnet test tests/GuideCms.Tests.csproj -c Release \
    --logger 'trx;LogFileName=green.trx' --results-directory records/test-results
...
통과!  - 실패:     0, 통과:    63, 건너뜀:     0, 전체:    63 - GuideCms.Tests.dll (net10.0)

63개 중 33개는 서비스, 데이터, 해시 검사이고, 30개는 WebApplicationFactory의 TestServer에서 요청을 보내는 검사입니다.[13]

AI가 작성한 테스트의 기대값 검토하기

Green은 구현이 Assert를 만족했다는 뜻입니다. 에이전트가 원본 분기를 잘못 읽으면 구현과 테스트가 같은 이유로 틀릴 수 있습니다. 통합 전에 대응표에서 원본 위치를 찾고, 변환 전에 적어 둔 기대값과 실제 Assert를 대조합니다.

로그인 테스트는 비활성 계정에 틀린 암호와 맞는 암호를 각각 넣어 서로 다른 실패 사유를 확인합니다. 홈 테스트는 PageID=3의 본문 중 ContentID=11이 선택되고, 더 최근에 수정된 ContentID=4가 제외되는지 확인합니다. 자동 대조 결과는 records/oracle-review.md에 남겼습니다.

예제에서는 Red 때의 테스트 파일 6개가 Green에서도 같은지 해시를 확인하고, HTTP 검증기 verify.sh를 통과한 코드를 통합 TD에 넘겼습니다.

5. 통합 TD를 실행하고 리팩토링 결과 확인하기

통합 전에는 변환 결과를 비교 기준으로 남깁니다. git log에서 변환 TD의 중간 커밋을 확인하고 남은 코드 변경도 검토해 커밋하세요. 이번 실행도 변환 완료 커밋을 기준으로 전후를 비교했습니다.

같은 폴더에서 TD 이름과 버전을 통합용으로 바꿔 실행합니다.

$ atx custom def exec -n asp-cms-integration \
    --tv 3hat9ov7fn6m6nsjag7ypxht -p . -x -t -d --classic

변환 직후 홈은 설정과 활성 상태, 본문과 메뉴를 각각 조회했습니다. 사이트가 활성화된 홈 요청에서는 이 네 호출이 JSON 파일을 네 번 읽고 설정 객체도 각각 만들었습니다. 다음은 IndexModel.OnGet의 실제 변경입니다.

-        Globals = homePages.GetGlobals();
-        SiteEnabled = homePages.IsSiteEnabled();
-        Home = SiteEnabled ? homePages.GetHomepage() : null;
-        Menu = homePages.GetMainMenu(Home?.PageFileName ?? "");
+        var screen = homePages.GetHomeScreen();
+        Globals = screen.Globals;
+        SiteEnabled = Globals.SiteEnabled;
+        Home = screen.Home;
+        Menu = screen.Menu;

새 GetHomeScreen은 데이터를 한 번 읽고 같은 사본에서 설정과 본문, 메뉴를 구성합니다. 원본의 선택 순서를 바꾸지 않고 조회 시점을 모은 것입니다.

public HomeScreen GetHomeScreen()
{
    var data = store.Load();
    var globals = new SiteGlobals(data);
    var home = globals.SiteEnabled ? SelectHomepage(data, globals) : null;
    return new HomeScreen(globals, home, BuildMainMenu(data, globals, home?.PageFileName ?? ""));
}

로그인 화면은 공통 설정을 읽기 위해 홈 서비스에 의존하고 있었습니다. 통합 TD는 요청 범위의 SiteGlobals를 직접 주입하도록 바꾸고, 사이트 활성 여부 판단도 설정 객체로 옮겼습니다. 테스트에서 사용하는 홈 선택과 메뉴 메서드의 이름 및 파라미터는 유지했습니다.

records/integration-result.md의 검사 결과를 줄이면 다음과 같습니다.

통합 전: 63/63 통과
통합 후: 63/63 통과, 테스트 이름 동일
Release: 경고 0, 오류 0
verify.sh: PASS, 실제 앱 HTTP 22 통과 / 0 실패
보호한 테스트와 입력 및 도구 14개: 해시 변경 없음

보호 파일 14개에는 테스트 파일 6개와 미리 준비한 입력 및 검증 도구가 포함됩니다.

6. 로컬 HTTP 요청과 브라우저로 두 화면 검증하기

Kestrel로 띄운 앱에 HTTP 요청을 보내 로그인 폼 전송, 인증 쿠키 발급, 홈의 관리자 링크 표시를 검사했습니다. 홈 본문과 로그인 폼의 렌더링은 Chrome에서 별도로 확인했습니다.

두 화면의 기존 .asp 주소는 Razor Pages 경로 설정으로 연결했습니다. 로그인 페이지에 @page "/admin/login.asp"를 지정하고 Program.cs에서 /admin/ 별칭을 추가했으며, 홈도 /와 /default.asp로 연결했습니다. 로그인 성공 처리는 원본의 DEBUG_OVERRIDE = "1" 분기로 고정했습니다. 이 분기에서 HTTP 200 응답에 성공 문구와 Continue 링크가 들어가는지 확인했습니다.

verify.sh로 Kestrel을 시작하고 요청 보내기

tools/verify.sh는 Release 빌드와 자동 테스트를 실행한 뒤 verify_source.py로 원본 파일 해시를 검사합니다. 이어서 테스트용 JSON 데이터로 Kestrel을 띄우고, 로그에서 동적 포트를 읽어 verify_http.py로 실제 요청을 보냅니다.[14] 종료 시에는 trap으로 앱 프로세스를 정리합니다.

실행한 verify.sh 전문 보기

#!/usr/bin/env bash
set -euo pipefail

root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
cd "$root"
mkdir -p .cache
run_dir=$(mktemp -d "$root/.cache/verify.XXXXXX")
app_pid=
cleanup() {
  if [[ -n "$app_pid" ]]; then
    kill "$app_pid" 2>/dev/null || true
    wait "$app_pid" 2>/dev/null || true
  fi
}
trap cleanup EXIT
trap 'exit 130' INT
trap 'exit 143' TERM

export DOTNET_CLI_HOME="$root/.cache/dotnet"
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_GENERATE_ASPNET_CERTIFICATE=false
export DOTNET_CLI_TELEMETRY_OPTOUT=1
dotnet build dotnet/WebSkeleton.csproj -c Release
dotnet test tests/GuideCms.Tests.csproj -c Release \
  --logger 'trx;LogFileName=tests.trx' --results-directory "$run_dir"
python3 tools/verify_source.py

export GUIDE_HTTP_FIXTURE_DIR="$run_dir/fixture"
export GUIDE_HTTP_RECORD="$run_dir/http.json"
python3 tools/verify_http.py --prepare
(
  cd dotnet
  exec env Cms__SeedPath="$GUIDE_HTTP_FIXTURE_DIR/seed.json" \
    Cms__DataPath="$GUIDE_HTTP_FIXTURE_DIR/data.json" \
    Cms__KeysPath="$GUIDE_HTTP_FIXTURE_DIR/keys" \
    dotnet bin/Release/net10.0/WebSkeleton.dll --urls http://127.0.0.1:0
) >"$run_dir/app.log" 2>&1 &
app_pid=$!
printf '%s\n' "$app_pid" >"$run_dir/app.pid"

base_url=
for ((i = 0; i < 100; i++)); do
  base_url=$(sed -nE 's|.*Now listening on: (http://127\.0\.0\.1:[0-9]+).*|\1|p' "$run_dir/app.log")
  [[ -n "$base_url" ]] && break
  if ! kill -0 "$app_pid" 2>/dev/null; then
    cat "$run_dir/app.log" >&2
    exit 1
  fi
  sleep 0.1
done
[[ -n "$base_url" ]] || { cat "$run_dir/app.log" >&2; exit 1; }
python3 tools/verify_http.py "$base_url"
printf 'PASS: Release build, tests, source hashes and HTTP checks. Logs: %s\n' "$run_dir"

verify_source.py는 보존 대상인 원본 654개 파일의 SHA-256 해시를 대조합니다. wwwroot/에 복사한 정적 파일 394개도 별도로 원본과 해시가 일치하는지 확인했습니다.

manifest = json.loads((root / 'records/source-manifest.json').read_text())
failures = []
for item in manifest['original_files']:
    path = root / 'original' / item['path']
    if not path.is_file() or hashlib.sha256(path.read_bytes()).hexdigest() != item['sha256']:
        failures.append(item['path'])
result = {'checked': len(manifest['original_files']), 'changed': failures}
print(json.dumps(result))
raise SystemExit(bool(failures))

verify_http.py는 같은 로그인 경로로 요청을 보내 CSRF 토큰 누락 시 HTTP 400 거부[15], 정상 로그인 시 HTTP 200과 인증 쿠키 발급, 응답 본문의 암호 노출 여부를 검사합니다. 이어서 아이디 저장 쿠키만 다른 클라이언트로 옮겨도 미인증 상태로 유지되는지, 마지막 로그인 기록이 런타임 사본에만 남는지 확인합니다.

check('POST without antiforgery is rejected', request('/admin/login.asp', {
    'action': 'login', 'UserID': 'unknown', 'Password': 'wrong'
})[0] == 400)

_, body = request('/admin/login.asp')
form = FormParser()
form.feed(body)
status, body = request('/admin/login.asp', {
    'action': 'login', 'UserID': synthetic_user, 'Password': synthetic_password,
    'RememberMe': 'ON', '__RequestVerificationToken': form.inputs.get('__RequestVerificationToken', '')
})
check('Synthetic account logs in', status == 200 and 'Your login credentials passed!' in body)
check('Authentication cookie is issued', any(c.name == 'GuideCms.Admin' for c in jar))
check('Password is absent from response', synthetic_password not in body)

실행 결과와 브라우저 확인

통합 TD가 끝난 뒤 같은 작업 폴더에서 verify.sh를 별도로 실행한 결과입니다.

$ bash tools/verify.sh
...
경고 0개
오류 0개
통과!  - 실패:     0, 통과:    63, 건너뜀:     0, 전체:    63 - GuideCms.Tests.dll (net10.0)
{"checked": 654, "changed": []}
{"passed": 22, "failed": 0}
PASS: Release build, tests, source hashes and HTTP checks. Logs: ...

Playwright로 헤드리스 Chrome을 실행해 홈과 로그인 페이지를 각각 열었습니다. 두 페이지 모두 HTTP 200으로 응답했고, 페이지 실행 오류나 HTTP 400 이상 응답은 기록되지 않았습니다. 캡처에서 홈 본문과 로그인 폼이 표시된 것을 확인했습니다.

상단 메뉴와 홈 본문이 표시된 CMS 화면

Chrome에서 확인한 전환 후 홈 화면

아이디와 암호 입력란, 아이디 저장 옵션이 표시된 관리자 로그인 폼

Chrome에서 확인한 전환 후 관리자 로그인 화면

7. 전환 범위를 나머지 화면으로 넓히기 전에

두 화면으로 절차를 확인했다면, 남은 화면에 적용할 때 실제로 부딪힐 지점은 세 가지입니다.

  • TD를 나누는 기준은 ‘같은 검증기로 확인할 수 있는가’입니다. 홈과 로그인은 같은 스켈레톤과 로컬 검증기로 묶을 수 있었습니다. 반면 실제 DB 연결을 옮길 때는 데이터와 통과 기준이 달라집니다. 원본 분석에서도 로그인 조회의 SQL 문자열 결합 문제가 지적됐으므로, DB 전환 TD를 따로 만들고 매개변수화 쿼리 검증을 통과 기준에 넣어야 합니다.
  • 화면이 늘수록 병목은 코드 작성이 아니라 기대값(oracle.md)입니다. Red 기록이나 해시 보호 같은 절차는 재사용할 수 있지만, 화면별 기대값은 매번 새로 써야 합니다. 누가 원본 분기를 읽고 기대값을 확정할지 먼저 정해 두어야 합니다.
  • 공통 파일은 통합 단계에서 정리합니다. 여러 묶음을 병렬로 전환할 때는 각 묶음이 수정할 파일을 먼저 정하고, 공통 코드는 통합 단계에서 정리합니다.

검증한 TD 게시하기

이번 파일럿은 Draft를 실행해 검증하는 단계까지 진행했습니다. 같은 AWS 계정과 리전을 쓰는 팀원에게 공유하려면 만료 전에 publish로 게시합니다. 명령의 --tv에는 직접 save-draft를 실행해 받은 버전을 넣으세요. 게시된 정의는 권한이 있는 팀원이 atx custom def list로 조회하고 실행할 수 있습니다.[11]

atx custom def publish -n asp-cms-port --tv "<변환 TD의 Draft 버전>"
atx custom def publish -n asp-cms-integration --tv "<통합 TD의 Draft 버전>"

팀에 공유할 때는 TD 버전과 함께 적용 범위, 실행 조건, 테스트와 HTTP 검사 결과를 남깁니다. 이번 TD에서 확인한 범위는 로컬 JSON 데이터를 사용하는 홈과 관리자 로그인 두 화면입니다. 다른 화면이나 실제 DB에 적용할 때는 해당 범위의 기대값과 검증 기준을 별도로 정해야 합니다.

마치며

레거시 코드를 AI 에이전트에 맡기기 전에 각 단계에서 무엇을 확인하고 넘어갈지 기준을 세웠습니다. 먼저 AWS Transform continuous modernization으로 원본을 분석해 보존할 동작을 골랐고, AWS Transform custom에서는 그 기준을 바탕으로 기능별 변환과 통합 리팩토링을 분리해 실행했습니다. 변환을 마친 시점에 동작을 검증해 두면, 통합 후 테스트가 실패하더라도 통합 단계에서 바뀐 코드부터 좁혀서 살펴볼 수 있습니다.

이번 파일럿에서는 원본 코드에서 정리한 기대값을 기준으로 테스트를 작성하고, 이 테스트를 변환과 통합 단계에 동일하게 적용했습니다. 파일 해시로 원본과 테스트 코드가 훼손되지 않았는지 검증했으며, 로컬 HTTP 요청으로 두 화면의 실제 동작을 확인했습니다.

다음 기능을 에이전트에게 맡길 때도 마찬가지입니다. 코드 소유자가 보존할 분기와 의도적으로 변경할 동작을 먼저 확정해야 합니다. 두 화면에서 구축한 검증 파이프라인은 그대로 재사용하되, 새 화면의 기대값만큼은 반드시 해당 원본 코드에 근거해 정의하시기 바랍니다.

참고

[1] AWS Transform 개요

[2] AWS Transform custom 소개

[3] AWS 관리형 변환 목록

[4] AWS 분석 유형 안내

[5] Classic ASP CMS 원본

[6] AWS CLI 사전 조건

[7] AWS 로컬 저장소 등록 안내

[8] AWS 분석 결과 조회

[9] Microsoft Razor Pages 구조

[10] AWS TD 구성 안내

[11] AWS CLI 명령 참조, AWS TD 게시와 버전 관리

[12] Microsoft 쿠키 인증

[13] Microsoft ASP.NET Core 통합 테스트

[14] Microsoft Kestrel 포트 설정

[15] CSRF 토큰 검증

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다