Skip to content

Port COSGN00C (Identity & Access / Signon) to C# .NET 8 (one-to-one) - #194

Open
matthewguerra-cog wants to merge 2 commits into
mainfrom
devin/1787763602-port-cosgn00c-csharp
Open

matthewguerra-cog wants to merge 2 commits into
mainfrom
devin/1787763602-port-cosgn00c-csharp

Conversation

@matthewguerra-cog

@matthewguerra-cog matthewguerra-cog commented Aug 26, 2026

Copy link
Copy Markdown

Summary

One-to-one port of app/cbl/COSGN00C.cbl (transaction CC00, signon) to C# on .NET 8 under a new dotnet/ tree. No COBOL was touched. Requested against ankehao-demo/aws-mainframe-modernization-carddemo, but Devin has no push access there (push: false, 403), so this lands on the COG-GTM fork — the COBOL/copybook sources are byte-identical between the two.

Paragraph → method, statement order preserved, no consolidation:

COBOL C# (dotnet/CardDemo.Identity/Cosgn00c.cs)
MAIN-PARA MainPara(TerminalInput eib)
PROCESS-ENTER-KEY ProcessEnterKey()
SEND-SIGNON-SCREEN SendSignonScreen()
SEND-PLAIN-TEXT SendPlainText()
POPULATE-HEADER-INFO PopulateHeaderInfo()
READ-USER-SEC-FILE ReadUserSecFile()

Copybooks → types with the exact PIC lengths: COCOM01YCardDemoCommarea (incl. the 88 levels as CdemoUsrtypAdmin/CdemoUsrtypUser/CdemoPgmEnter/CdemoPgmReenter), CSUSR01YSecUserData (SecUsrId X(8), SecUsrFname X(20), SecUsrLname X(20), SecUsrPwd X(8), SecUsrType X(1), SecUsrFiller X(23)), COSGN00.CPYCosgn0aMap (single object because COSGN0AO REDEFINES COSGN0AI; UseridL/PasswdL carry the -1 cursor), CSMSG01Y/COTTL01YCcdaCommonMessages/CcdaScreenTitle literals copied verbatim including trailing blanks of the PIC X(50)/X(40) VALUE clauses.

CICS is abstracted only at the boundary: ICicsTerminal (RECEIVE MAP / SEND MAP / SEND TEXT / ASSIGN APPLID+SYSID), IUserSecurityFile.Read(dataset, key, into) returning the raw RESP code (0 / 13 / other, CicsRespCodes), IProgramControl.Xctl(program, commarea), and TerminalInput(EibCalen, EibAid) for the EIB fields. CobolString reproduces MOVE truncate/space-pad, SPACES/LOW-VALUES comparison and FUNCTION UPPER-CASE (invariant).

Faithfulness details worth calling out:

  • The uppercasing MOVEs sit after the EVALUATE in PROCESS-ENTER-KEY, so they run on the empty-User-ID / empty-Password branches too; the IF NOT ERR-FLG-ON guard is what suppresses the read. Preserved literally — CdemoUserId is populated even when validation failed and no read happens.
  • SEND-PLAIN-TEXT issues a bare EXEC CICS RETURN, and XCTL never returns, so neither path reaches MAIN-PARA's RETURN TRANSID('CC00'). Modeled with an internal _taskEnded flag rather than exceptions; observable via ReturnTransid (null on those paths) and XctlProgram.
  • CARDDEMO-COMMAREA is WORKING-STORAGE in the COBOL (DFHCOMMAREA is never copied in), so CarddemoCommarea starts blank per invocation and only EIBCALEN is consumed from the passed commarea.
  • Wrong-password does not set WS-ERR-FLG in the COBOL (only the message + cursor); kept as-is.
  • Non-admin user types other than 'U' fall to the ELSE and route to COMEN01C (covered by a test).

Copybooks were all located in app/cpy/ (CSUSR01Y.cpy, CSMSG01Y.cpy, COTTL01Y.cpy, CSDAT01Y.cpy), so no field layouts or literals were invented. Only assumption: FUNCTION CURRENT-DATE is injected as Func<DateTime> (defaults to DateTime.Now) so header date/time (mm/dd/yy, hh:mm:ss from CSDAT01Y) is deterministic in tests.

Security preserved as-is (not modernized): password comparison is plaintext after uppercasing, USRSEC is read-only, and there is no lockout, retry counter, or audit logging — exactly as in the COBOL. Do not treat this port as hardened authentication.

Tests

dotnet/CardDemo.Identity.Tests/Cosgn00cTests.cs, xUnit, dotnet test19 passed / 0 failed:

EIBCALEN=0 sends the screen with cursor on User ID and no read · header fields populated (titles, CC00, COSGN00C, date/time, applid/sysid) · PF3 sends the CCDA-MSG-THANK-YOU plain text, no map, no routing · unknown key shows CCDA-MSG-INVALID-KEY and redisplays · empty User ID (spaces and low-values) → "Please enter User ID ..." with cursor on User ID, no read · empty Password (spaces and low-values) → "Please enter Password ..." with cursor on Password, no read · CDEMO-USER-ID still uppercased on the error branch · valid admin → commarea (CC00, COSGN00C, uppercased id, type A, context 0) and XCTL COADM01C · valid user → COMEN01C · type XCOMEN01C · wrong password → "Wrong Password. Try again ..." cursor Password, no routing · RESP 13 → "User not found. Try again ..." cursor User ID · other RESP → "Unable to verify the User ..." cursor User ID · lowercase admin001/password uppercased before lookup and compare · read targets dataset USRSEC · pseudo-conversational retry (failed then successful signon) · stored record unchanged after signon.

Devin-Org: engineering

Link to Devin session: https://app.devin.ai/sessions/550ae3504118489782ce5cddc3712d0f
Requested by: @matthewguerra-cog


Devin Review

Status Commit
🟢 Reviewed 33e6c1f
Devin Review (Staging)

…ith xUnit tests

Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

staging-devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
devin-ai-integration[bot]

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant