-
Notifications
You must be signed in to change notification settings - Fork 7
SDMEXT-616: Implementing user token flow;Ccahing of user token: basic create attachment flow #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
POC for create attachment
Caching the DI token for 11 hours
<artifactId>junit-jupiter-api</artifactId> | ||
<version>5.10.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this removed? Are you able to run UTs without this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added back
/************************************************************************** | ||
* (C) 2019-2024 SAP SE or an SAP affiliate company. All rights reserved. * | ||
**************************************************************************/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this
var outbox = configurer.getCdsRuntime().getServiceCatalog().getService(OutboxService.class, | ||
OutboxService.PERSISTENT_UNORDERED_NAME);//need to check if required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IS this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is required now as for a method its mandatory can be removed later
if (cachedToken == null) { | ||
cachedToken= generateDITokenFromTokenExchange(token,sdmCredentials,payloadObj); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not caching DI token?
} | ||
return cachedToken; | ||
} | ||
public static String getDIToken(String token,SDMCredentials sdmCredentials) throws OAuth2ServiceException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix indentation. Put spaces between method parameters
cacheKey.setExpiration(token_expiry); | ||
String cachedToken = CacheConfig.getUserTokenCache().get(cacheKey); | ||
if (cachedToken == null) { | ||
cachedToken= generateDITokenFromTokenExchange(token,sdmCredentials,payloadObj); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix indentation. Put spaces between method parameters
return cachedToken; | ||
} | ||
|
||
private static String generateDITokenFromTokenExchange(String token,SDMCredentials sdmCredentials,JsonObject payloadObj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix indentation. Put spaces between method parameters
|
||
private static String generateDITokenFromTokenExchange(String token,SDMCredentials sdmCredentials,JsonObject payloadObj) | ||
throws OAuth2ServiceException { | ||
String cachedToken =null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix indentation. Put spaces after =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 17, is it fine to hardcode that value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed it
pom.xml
Outdated
<artifactId>junit-jupiter-api</artifactId> | ||
<artifactId>junit-jupiter</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be junit-jupiter-api
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<version>5.12.0</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this version back
POC for create attachment