Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/restore-tokens-component-in-IAM-…
Browse files Browse the repository at this point in the history
…dashboard' into v1.8.0
  • Loading branch information
enricovianello committed Feb 16, 2022
2 parents 4efd231 + 256714a commit cbafc73
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 22 deletions.
2 changes: 1 addition & 1 deletion compose/nginx-local-dev/docker-compose_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ services:
- iam.local.io

extra_hosts:
- "host.docker.internal:host-gateway"
- "host.docker.internal:host-gateway"
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private ClientRef buildClientRef(String clientId) {
return ClientRef.builder()
.id(cd.getId())
.clientId(cd.getClientId())
.clientName(cd.getClientName())
.contacts(cd.getContacts())
.ref(cd.getClientUri())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ public class ClientRef {

private Long id;
private String clientId;
private String clientName;
private Set<String> contacts;
private String ref = null;

@JsonCreator
public ClientRef(@JsonProperty("id") Long id, @JsonProperty("clientId") String clientId,
public ClientRef(@JsonProperty("id") Long id, @JsonProperty("clientId") String clientId, @JsonProperty("clientName") String clientName,
@JsonProperty("contacts") Set<String> contacts, @JsonProperty("$ref") String ref) {

this.id = id;
this.clientId = clientId;
this.clientName = clientName;
this.contacts = contacts;
this.ref = ref;
}
Expand All @@ -43,6 +45,7 @@ public ClientRef(Builder builder) {

this.id = builder.id;
this.clientId = builder.clientId;
this.clientName = builder.clientName;
this.contacts = builder.contacts;
this.ref = builder.ref;
}
Expand All @@ -58,6 +61,12 @@ public String getClientId() {

return clientId;
}

@JsonProperty("clientName")
public String getClientName() {

return clientName;
}

@JsonProperty("contacts")
public Set<String> getContacts() {
Expand All @@ -74,7 +83,7 @@ public String getRef() {
@Override
public String toString() {

return "Client [id=" + id + ", clientId=" + clientId + ", contacts=" + contacts
return "Client [id=" + id + ", clientId=" + clientId + ", clientName=" + clientName + ", contacts=" + contacts
+ ", ref=" + ref + "]";
}

Expand All @@ -87,6 +96,7 @@ public static class Builder {

private Long id;
private String clientId;
private String clientName;
private Set<String> contacts;
private String ref;

Expand All @@ -99,6 +109,11 @@ public Builder clientId(String clientId) {
this.clientId = clientId;
return this;
}

public Builder clientName(String clientName) {
this.clientName = clientName;
return this;
}

public Builder contacts(Set<String> contacts) {
this.contacts = contacts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
<div class="col-md-5">

<ui-select id="atok_client_search_btn" ng-model="$ctrl.clientSelected" theme="bootstrap" sortable="true" close-on-select="true" input-id="atok_client_search" style="width: 100%;" on-select="$ctrl.searchTokens(1)">
<ui-select-match allow-clear="true" placeholder="Filter tokens by client...">{{$ctrl.clientSelected.clientId}}</ui-select-match>
<ui-select-choices repeat="client in $ctrl.clients | filter: {clientId: $select.search}">
<div ng-bind-html="client.clientId | highlight: $select.search"></div>
<small> {{ client.clientName }} </small>
<ui-select-match allow-clear="true" placeholder="Filter tokens by client...">{{$ctrl.clientSelected.client_name}}</ui-select-match>
<ui-select-choices repeat="client in $ctrl.clients | filter: {client_name: $select.search}">
<div ng-bind-html="client.client_name | highlight: $select.search"></div>
<small> {{ client.client_id }} </small>
</ui-select-choices>
<ui-select-no-choice> No results found </ui-select-no-choice>
</ui-select>
Expand Down Expand Up @@ -80,7 +80,9 @@
<h5>{{$index + $ctrl.currentOffset}}</h5>
</td>
<td class="align-middle">
<h5><a ui-sref="client({id: token.client.id})">{{token.client.clientId}}</a></h5>
<a ui-sref="client({id: token.client.clientId})">{{token.client.clientName}}</a>
<br/>
<small>{{token.client.clientId}}</small>
</td>
<td class="align-middle" ng-if="token.user != null">
<a ui-sref="user({id: token.user.id})">{{token.user.userName}}</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@

self.getAccessTokenList = function(startIndex, count) {
if (self.clientSelected && self.userSelected) {
return TokensService.getAccessTokensFilteredByUserAndClient(startIndex, count, self.userSelected.userName, self.clientSelected.clientId);
return TokensService.getAccessTokensFilteredByUserAndClient(startIndex, count, self.userSelected.userName, self.clientSelected.client_id);
}
if (self.clientSelected) {
return TokensService.getAccessTokensFilteredByClient(startIndex, count, self.clientSelected.clientId);
return TokensService.getAccessTokensFilteredByClient(startIndex, count, self.clientSelected.client_id);
}
if (self.userSelected) {
return TokensService.getAccessTokensFilteredByUser(startIndex, count, self.userSelected.userName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<div class="row">
<div class="col-md-5">
<ui-select id="rtok_client_search_btn" ng-model="$ctrl.clientSelected" theme="bootstrap" sortable="true" close-on-select="true" input-id="rtok_client_search" style="width: 100%;" on-select="$ctrl.searchTokens(1)">
<ui-select-match allow-clear="true" placeholder="Filter tokens by client...">{{$ctrl.clientSelected.clientId}}</ui-select-match>
<ui-select-choices repeat="client in $ctrl.clients | filter: {clientId: $select.search}">
<div ng-bind-html="client.clientId | highlight: $select.search"></div>
<small> {{ client.clientName }} </small>
<ui-select-match allow-clear="true" placeholder="Filter tokens by client...">{{$ctrl.clientSelected.client_name}}</ui-select-match>
<ui-select-choices repeat="client in $ctrl.clients | filter: {client_name: $select.search}">
<div ng-bind-html="client.client_name | highlight: $select.search"></div>
<small> {{ client.client_id }} </small>
</ui-select-choices>
<ui-select-no-choice> No results found </ui-select-no-choice>
</ui-select>
Expand Down Expand Up @@ -79,7 +79,7 @@
<h5>{{$index + $ctrl.currentOffset}}</h5>
</td>
<td class="align-middle">
<h5><a ui-sref="client({id: token.client.id})">{{token.client.clientId}}</a></h5>
<h5><a ui-sref="client({id: token.client.clientId})">{{token.client.clientId}}</a></h5>
</td>
<td class="align-middle" ng-if="token.user != null">
<a ui-sref="user({id: token.user.id})">{{token.user.userName}}</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@

self.getRefreshTokenList = function(startIndex, count) {
if (self.clientSelected && self.userSelected) {
return TokensService.getRefreshTokensFilteredByUserAndClient(startIndex, count, self.userSelected.userName, self.clientSelected.clientId);
return TokensService.getRefreshTokensFilteredByUserAndClient(startIndex, count, self.userSelected.userName, self.clientSelected.client_id);
}
if (self.clientSelected) {
return TokensService.getRefreshTokensFilteredByClient(startIndex, count, self.clientSelected.clientId);
return TokensService.getRefreshTokensFilteredByClient(startIndex, count, self.clientSelected.client_id);
}
if (self.userSelected) {
return TokensService.getRefreshTokensFilteredByUser(startIndex, count, self.userSelected.userName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@

self.loadClients = function() {
return ClientsService.getClientList().then(function(r) {
self.clients = r.data;
var c = r.data;
self.clients = c['Resources'];
console.log('all clients received');
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@
retrieveClientOwners: retrieveClientOwners,
assignClientOwner: assignClientOwner,
removeClientOwner: removeClientOwner,
newClient: newClient
newClient: newClient,
getClientList: getClientList
};

return service;

function getClientList(){
return $http.get(clientsEndpoint);
}

function endpoint(clientId) {
return clientsEndpoint + '/' + clientId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ public void testRatWorkAsExpected() {
managementService.rotateRegistrationAccessToken(getResponse.getClientId());

assertThat(rotatedRatClient.getRegistrationAccessToken(), notNullValue());


try {

RestAssured.given()
.auth()
.oauth2(registerResponse.getRegistrationAccessToken())
Expand All @@ -128,7 +130,12 @@ public void testRatWorkAsExpected() {
.get(registerUrl + "/" + registerResponse.getClientId())
.then()
.statusCode(HttpStatus.OK.value());

}

finally {
managementService.deleteClientByClientId(getResponse.getClientId());
}

}

@Test
Expand All @@ -149,7 +156,7 @@ public void testRedeemClientFlow() {
.statusCode(HttpStatus.CREATED.value())
.extract().body().as(RegisteredClientDTO.class);
// @formatter:on

try {
assertThat(registerResponse.getRegistrationAccessToken(), notNullValue());
assertThat(registerResponse.getScope(), not(empty()));

Expand Down Expand Up @@ -204,6 +211,10 @@ public void testRedeemClientFlow() {
.statusCode(HttpStatus.OK.value())
.body("totalResults", equalTo(1))
.body("Resources[0].client_id", equalTo(registerResponse.getClientId()));
}
finally {
managementService.deleteClientByClientId(registerResponse.getClientId());
}
}

}

0 comments on commit cbafc73

Please sign in to comment.