1919--
2020-- ============================================================================
2121
22- CREATE MODULE AuthTest;
22+ create module AuthTest;
2323
2424-- ############################################################################
2525-- PART 1: CONSTANTS FOR AUTH CREDENTIALS
@@ -29,8 +29,8 @@ CREATE MODULE AuthTest;
2929-- Literal strings in Authentication: BASIC (...) are auto-promoted to
3030-- constants by mxcli. For explicit control, create constants first:
3131
32- CREATE CONSTANT AuthTest.ApiUser TYPE String DEFAULT 'testuser';
33- CREATE CONSTANT AuthTest.ApiPass TYPE String DEFAULT 'testpass123!';
32+ create constant AuthTest.ApiUser type string default 'testuser';
33+ create constant AuthTest.ApiPass type string default 'testpass123!';
3434
3535-- ############################################################################
3636-- PART 2: REST CLIENT WITH BASIC AUTH
@@ -40,18 +40,18 @@ CREATE CONSTANT AuthTest.ApiPass TYPE String DEFAULT 'testpass123!';
4040-- Basic auth credentials are sent, 401 otherwise.
4141-- This is the definitive test: if we get 200, the header was sent.
4242
43- CREATE REST CLIENT AuthTest.HttpBinAuthAPI (
43+ create rest client AuthTest.HttpBinAuthAPI (
4444 BaseUrl: 'https://httpbin.org',
45- Authentication: BASIC (Username : @AuthTest.ApiUser, Password : @AuthTest.ApiPass)
45+ authentication: basic (username : @AuthTest.ApiUser, password : @AuthTest.ApiPass)
4646)
4747{
4848 /** Calls /basic-auth/testuser/testpass123! — returns 200 if auth header sent */
49- OPERATION CheckAuth {
50- Method: GET ,
51- Path : '/basic-auth/testuser/testpass123!',
52- Headers : ('Accept' = 'application/json'),
53- Timeout : 30,
54- Response: NONE
49+ operation CheckAuth {
50+ method: get ,
51+ path : '/basic-auth/testuser/testpass123!',
52+ headers : ('Accept' = 'application/json'),
53+ timeout : 30,
54+ response: none
5555 }
5656};
5757
@@ -67,24 +67,24 @@ CREATE REST CLIENT AuthTest.HttpBinAuthAPI (
6767 * 200 = auth header sent correctly
6868 * 401 = auth header missing or wrong (BUG #200)
6969 */
70- CREATE MICROFLOW AuthTest.ACT_TestBasicAuth ()
71- RETURNS Boolean AS $Success
72- BEGIN
73- DECLARE $Success Boolean = false;
70+ create microflow AuthTest.ACT_TestBasicAuth ()
71+ returns boolean as $success
72+ begin
73+ declare $success boolean = false;
7474
7575 -- Call the REST client operation
76- SEND REST REQUEST AuthTest.HttpBinAuthAPI.CheckAuth;
76+ send rest request AuthTest.HttpBinAuthAPI.CheckAuth;
7777
7878 -- Check the response status
79- IF $latestHttpResponse/StatusCode = 200 THEN
80- LOG INFO NODE 'AuthTest' 'Auth OK: 200 — Basic auth header was sent correctly';
81- SET $Success = true;
82- ELSE
83- LOG WARNING NODE 'AuthTest' 'Auth FAILED: status=' + toString($latestHttpResponse/StatusCode) + ' — Basic auth header was NOT sent (bug #200)';
84- END IF ;
85-
86- RETURN $Success ;
87- END ;
79+ if $latestHttpResponse/StatusCode = 200 then
80+ log info node 'AuthTest' 'Auth OK: 200 — Basic auth header was sent correctly';
81+ set $success = true;
82+ else
83+ log warning node 'AuthTest' 'Auth FAILED: status=' + toString($latestHttpResponse/StatusCode) + ' — Basic auth header was NOT sent (bug #200)';
84+ end if ;
85+
86+ return $success ;
87+ end ;
8888/
8989
9090-- ############################################################################
9797 * ACT_TestBasicAuthInline succeeds, the bug is in the REST client
9898 * auth serialization.
9999 */
100- CREATE MICROFLOW AuthTest.ACT_TestBasicAuthInline ()
101- RETURNS Boolean AS $Success
102- BEGIN
103- DECLARE $Success Boolean = false;
104-
105- $Response = REST CALL GET 'https://httpbin.org/basic-auth/testuser/testpass123!'
106- HEADER Accept = 'application/json'
107- AUTH BASIC 'testuser' PASSWORD 'testpass123!'
108- TIMEOUT 30
109- RETURNS String
110- ON ERROR CONTINUE ;
111-
112- IF $Response != '' THEN
113- LOG INFO NODE 'AuthTest' 'Inline auth OK — response received';
114- SET $Success = true;
115- ELSE
116- LOG WARNING NODE 'AuthTest' 'Inline auth FAILED — empty response';
117- END IF ;
118-
119- RETURN $Success ;
120- END ;
100+ create microflow AuthTest.ACT_TestBasicAuthInline ()
101+ returns boolean as $success
102+ begin
103+ declare $success boolean = false;
104+
105+ $response = rest call get 'https://httpbin.org/basic-auth/testuser/testpass123!'
106+ header Accept = 'application/json'
107+ auth basic 'testuser' password 'testpass123!'
108+ timeout 30
109+ returns string
110+ on error continue ;
111+
112+ if $response != '' then
113+ log info node 'AuthTest' 'Inline auth OK — response received';
114+ set $success = true;
115+ else
116+ log warning node 'AuthTest' 'Inline auth FAILED — empty response';
117+ end if ;
118+
119+ return $success ;
120+ end ;
121121/
122122
123123-- ############################################################################
124124-- PART 4: TEST PAGE
125125-- ############################################################################
126126
127- CREATE PAGE AuthTest.AuthTestPage
127+ create page AuthTest.AuthTestPage
128128(
129- Title : 'Bug #200 — Basic Auth Test',
130- Layout : Atlas_Core.Atlas_Default,
131- Url : 'auth-test'
129+ title : 'Bug #200 — Basic Auth Test',
130+ layout : Atlas_Core.Atlas_Default,
131+ url : 'auth-test'
132132)
133133{
134- LAYOUTGRID grid {
135- ROW rowTitle {
136- COLUMN col (DesktopWidth : 12) {
137- DYNAMICTEXT txtTitle (Content : 'Bug #200: REST Client Basic Auth', RenderMode : H2)
138- DYNAMICTEXT txtDesc (Content : 'Click each button and check the console log. Both should show status 200.', RenderMode: Paragraph )
134+ layoutgrid grid {
135+ row rowTitle {
136+ column col (desktopwidth : 12) {
137+ dynamictext txtTitle (content : 'Bug #200: REST Client Basic Auth', rendermode : H2)
138+ dynamictext txtDesc (content : 'Click each button and check the console log. Both should show status 200.', rendermode: paragraph )
139139 }
140140 }
141- ROW rowButtons {
142- COLUMN colClient (DesktopWidth : 6) {
143- ACTIONBUTTON btnClient (
144- Caption : 'Test REST Client Auth',
145- Action: MICROFLOW AuthTest.ACT_TestBasicAuth,
146- ButtonStyle: Primary
141+ row rowButtons {
142+ column colClient (desktopwidth : 6) {
143+ actionbutton btnClient (
144+ caption : 'Test REST Client Auth',
145+ action: microflow AuthTest.ACT_TestBasicAuth,
146+ buttonstyle: primary
147147 )
148- DYNAMICTEXT txtClient (Content : 'Uses CREATE REST CLIENT with BASIC auth', RenderMode: Paragraph )
148+ dynamictext txtClient (content : 'Uses CREATE REST CLIENT with BASIC auth', rendermode: paragraph )
149149 }
150- COLUMN colInline (DesktopWidth : 6) {
151- ACTIONBUTTON btnInline (
152- Caption : 'Test Inline REST CALL Auth',
153- Action: MICROFLOW AuthTest.ACT_TestBasicAuthInline,
154- ButtonStyle: Default
150+ column colInline (desktopwidth : 6) {
151+ actionbutton btnInline (
152+ caption : 'Test Inline REST CALL Auth',
153+ action: microflow AuthTest.ACT_TestBasicAuthInline,
154+ buttonstyle: default
155155 )
156- DYNAMICTEXT txtInline (Content : 'Uses inline REST CALL ... AUTH BASIC (known working)', RenderMode: Paragraph )
156+ dynamictext txtInline (content : 'Uses inline REST CALL ... AUTH BASIC (known working)', rendermode: paragraph )
157157 }
158158 }
159159 }
@@ -163,6 +163,6 @@ CREATE PAGE AuthTest.AuthTestPage
163163-- PART 5: VERIFICATION
164164-- ############################################################################
165165
166- SHOW REST CLIENTS IN AuthTest;
167- DESCRIBE REST CLIENT AuthTest.HttpBinAuthAPI;
168- DESCRIBE MICROFLOW AuthTest.ACT_TestBasicAuth;
166+ show rest clients in AuthTest;
167+ describe rest client AuthTest.HttpBinAuthAPI;
168+ describe microflow AuthTest.ACT_TestBasicAuth;
0 commit comments