Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
@FeignClient(name="account", url="${obp.api.rootUrl}")
public interface DirectAuthenticationClient {

@RequestMapping(method = RequestMethod.GET, value = "${obp.api.directLoginPath}")
@RequestMapping(method = RequestMethod.POST, value = "${obp.api.directLoginPath}")
Token loginInternal(@RequestHeader("Authorization") String authHeader);

default String login(String username, String password, String consumerKey) {
val dlData = String.format("DirectLogin username=%s,password=%s,consumer_key=%s", username, password, consumerKey);
val dlData = String.format("DirectLogin username=\"%s\",password=\"%s\",consumer_key=\"%s\"", username, password, consumerKey);
val token = loginInternal(dlData).getToken();
val authentication = new UsernamePasswordAuthenticationToken(username, token);
SecurityContextHolder.getContext().setAuthentication(authentication);
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/com/tesobe/obp/clientapi/ObpApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public interface ObpApiClient {

//tag::my-account[]
@RequestMapping(method = RequestMethod.GET, value = "my/accounts")
List<Account> getPrivateAccountsNoDetails();
Accounts getPrivateAccountsNoDetails();

default List<Account> getPrivateAccountsWithDetails() {
List<Account> accountsNoDetails = getPrivateAccountsNoDetails();
List<Account> accountsNoDetails = getPrivateAccountsNoDetails().getAccounts();
return accountsNoDetails.stream().map(account -> getAccount(account.getBankId(), account.getId())).collect(Collectors.toList());
}

Expand Down Expand Up @@ -97,4 +97,9 @@ class TransactionRequestTypes {
class AccountViews {
private List<AccountView> views;
}

@Data
class Accounts {
private List<Account> accounts;
}
}
12 changes: 6 additions & 6 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
obp.api.rootUrl=https://danskebank.openbankproject.com
obp.api.rootUrl=https://apisandbox.openbankproject.com

obp.api.versionedUrl:${obp.api.rootUrl}/obp/v2.2.0
obp.api.versionedUrl:${obp.api.rootUrl}/obp/v3.1.0
obp.api.directloginUrl=${obp.api.rootUrl}/my/logins/direct
obp.api.directLoginPath=/my/logins/direct

obp.consumerKey=your-api-key-here
obp.username=your-username-here
obp.password=your-password-here
obp.consumerKey=e3bh0v3faaveysnwqnb1kv42lpnhqjbxvw2adphf
obp.username=testdude
obp.password=testdudeA1!

security.basic.enabled=false
security.basic.enabled=false
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ public void badCredentials() throws Exception {
try {
directAuthenticationClient.login(username, password, "garble");
} catch (Exception ex) {
Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, ((FeignException)ex.getCause().getCause()).status());
Throwable ex2 = ex;
while (ex2 != null && !(ex2 instanceof FeignException)) {
ex2 = ex2.getCause();
}
Assert.assertNotNull("There should be a FeignException in the exception cause chain, but was " + ex, ex);
Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, (FeignException) ex);
return;
}
Assert.assertFalse("Should have gotten 401 exception", true);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/tesobe/obp/domain/AccountServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class AccountServiceTest extends AbstractTestSupport {
@Test
public void fetchPrivateAccountsNoDetailsOk() {
//fetch private accounts
List<Account> privateAccounts = obpApiClient.getPrivateAccountsNoDetails();
List<Account> privateAccounts = obpApiClient.getPrivateAccountsNoDetails().getAccounts();
assertTrue(privateAccounts.size() > 0);
}

Expand All @@ -37,7 +37,7 @@ public void fetchPrivateAccountsWithDetailsOk() {

@Test
public void accountViewsOk() throws Exception {
List<Account> privateAccounts = obpApiClient.getPrivateAccountsNoDetails();
List<Account> privateAccounts = obpApiClient.getPrivateAccountsNoDetails().getAccounts();
Account firstAccount = privateAccounts.get(0);
ObpApiClient.AccountViews views = obpApiClient.getViewsForAccount(firstAccount.getBankId(), firstAccount.getId());
Assert.assertNotNull(views);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MonetaryTransactionsServiceTest extends AbstractTestSupport {

@Test
public void fetchTransactionListOk() throws Exception {
List<Account> accounts = obpApiClient.getPrivateAccountsNoDetails();
List<Account> accounts = obpApiClient.getPrivateAccountsNoDetails().getAccounts();
Assert.assertTrue(accounts.size() > 0);

String bankId = accounts.get(0).getBankId();
Expand Down