Skip to content

Commit 95e5153

Browse files
Merge branch 'main' into shared-xml-id-validation
2 parents 3a848ee + e333607 commit 95e5153

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

.changeset/pink-buckets-sort.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sap-ux/generator-adp": patch
3+
---
4+
5+
fix(generator-adp): Change endpoint used for checking user authentication

packages/generator-adp/src/base/questions/credentials.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ function getPasswordPrompt(abapTarget: AbapTarget, logger: ToolsLogger): Passwor
9292
}
9393

9494
/**
95-
* Helper function which asserts whether a client is authenticated on an ABAP system or throws.
9695
* Since we do not have a dedicated api call to detect if a client is authenticated we use the
97-
* {@link LayeredRepositoryService.getSystemInfo} call which is a protected one.
96+
* {@link LayeredRepositoryService.getCsrfToken} call which is a protected one.
9897
*
9998
* @param {ClientCredentials} credentials - Object containing client credentials to a specific ABAP system.
10099
* @param {ToolsLogger} logger - The logger instance.
@@ -104,5 +103,5 @@ function getPasswordPrompt(abapTarget: AbapTarget, logger: ToolsLogger): Passwor
104103
async function assertAuthenticated(credentials: ClientCredentials, logger: ToolsLogger): Promise<void> {
105104
const abapProvider = await getConfiguredProvider(credentials, logger);
106105
const layeredRepositoryService = abapProvider.getLayeredRepository();
107-
await layeredRepositoryService.getSystemInfo();
106+
await layeredRepositoryService.getCsrfToken();
108107
}

packages/generator-adp/test/unit/base/questions/credentials.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ describe('Credentials Prompts', () => {
110110

111111
describe('Password Prompt', () => {
112112
let passwordPrompt: any;
113-
let mockGetSystemInfo: jest.Mock;
113+
let mockGetCsrfToken: jest.Mock;
114114

115115
beforeEach(() => {
116116
const result = getCredentialsPrompts(mockAbapTarget, mockLogger);
117117
passwordPrompt = result[1];
118-
mockGetSystemInfo = jest.fn();
118+
mockGetCsrfToken = jest.fn();
119119
mockGetConfiguredProvider.mockResolvedValue({
120-
getLayeredRepository: () => ({ getSystemInfo: mockGetSystemInfo })
120+
getLayeredRepository: () => ({ getCsrfToken: mockGetCsrfToken })
121121
} as unknown as AbapServiceProvider);
122122
});
123123

@@ -139,7 +139,7 @@ describe('Credentials Prompts', () => {
139139
mockIsAppStudio.mockReturnValue(false);
140140
mockAbapTarget.url = 'some-system';
141141
mockValidateEmptyString.mockReturnValue(true);
142-
mockGetSystemInfo.mockResolvedValue({});
142+
mockGetCsrfToken.mockResolvedValue({});
143143

144144
const prompts = getCredentialsPrompts(mockAbapTarget, mockLogger);
145145
const passwordPrompt = prompts[1];
@@ -159,15 +159,15 @@ describe('Credentials Prompts', () => {
159159
},
160160
mockLogger
161161
);
162-
expect(mockGetSystemInfo).toHaveBeenCalled();
162+
expect(mockGetCsrfToken).toHaveBeenCalled();
163163
expect(result).toBe(true);
164164
});
165165

166166
it('should use destination when in AppStudio', async () => {
167167
mockIsAppStudio.mockReturnValue(true);
168168
mockAbapTarget.destination = 'SYS_010';
169169
mockValidateEmptyString.mockReturnValue(true);
170-
mockGetSystemInfo.mockResolvedValue({});
170+
mockGetCsrfToken.mockResolvedValue({});
171171

172172
const prompts = getCredentialsPrompts(mockAbapTarget, mockLogger);
173173
const passwordPrompt = prompts[1];
@@ -187,7 +187,7 @@ describe('Credentials Prompts', () => {
187187
},
188188
mockLogger
189189
);
190-
expect(mockGetSystemInfo).toHaveBeenCalled();
190+
expect(mockGetCsrfToken).toHaveBeenCalled();
191191
expect(result).toBe(true);
192192
});
193193

@@ -230,7 +230,7 @@ describe('Credentials Prompts', () => {
230230
statusText: 'Unauthorized'
231231
}
232232
};
233-
mockGetSystemInfo.mockRejectedValue(mockError);
233+
mockGetCsrfToken.mockRejectedValue(mockError);
234234

235235
const prompts = getCredentialsPrompts(mockAbapTarget, mockLogger);
236236
const passwordPrompt = prompts[1];

0 commit comments

Comments
 (0)