Skip to content

Commit

Permalink
Fixed build, disabled test GraphClient with local git ignored properties
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Oct 14, 2023
1 parent 6f467f8 commit db7060f
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions server/src/main/java/access/api/InvitationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ public ResponseEntity<Map<String, String>> accept(@Validated @RequestBody Accept
user.setLastActivity(Instant.now());

invitation.setStatus(Status.ACCEPTED);
invitation.setSubInvitee(sub);
invitationRepository.save(invitation);
AccessLogger.invitation(LOG, Event.Accepted, invitation);

Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/access/api/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public View msAcceptReturn(@PathVariable("sub") String sub) {
Map<String, Object> provisioningMap = manage.providerById(EntityType.PROVISIONING, remoteProvisionedUser.getManageProvisioningId());
Provisioning provisioning = new Provisioning(provisioningMap);
graphClient.updateUserRequest(user, provisioning, remoteProvisionedUser.getRemoteIdentifier());
//TODO, this does not work as the invitation is accepted with a different email. Store something on the invitation for the graph repsonse
String invitationHash = invitationRepository.findTopByEmailOrderByCreatedAtDesc(user.getEmail()).map(Invitation::getHash).orElse("");
String invitationHash = invitationRepository.findTopBySubInviteeOrderByCreatedAtDesc(user.getSub())
.map(Invitation::getHash).orElse("");
String redirectUrl = String.format("%s/proceed?hash=%s&isRedirect=true", config.getWelcomeUrl(), invitationHash);
redirectReference.set(redirectUrl);
});
Expand Down
3 changes: 3 additions & 0 deletions server/src/main/java/access/model/Invitation.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class Invitation implements Serializable {
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String hash;

@Column(name = "sub_invitee")
private String subInvitee;

@Column(name = "enforce_email_equality")
private boolean enforceEmailEquality;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface InvitationRepository extends JpaRepository<Invitation, Long> {
attributePaths = {"inviter", "roles", "roles.role"})
Optional<Invitation> findByHash(String hash);

Optional<Invitation> findTopByEmailOrderByCreatedAtDesc(String email);
Optional<Invitation> findTopBySubInviteeOrderByCreatedAtDesc(String email);

List<Invitation> findByStatusAndRoles_role(Status status, Role role);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE `invitations`
add `sub_invitee` varchar(255) DEFAULT NULL;
3 changes: 3 additions & 0 deletions server/src/test/java/access/Seed.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public void doSeed() {
new Invitation(Authority.GUEST, Authority.GUEST.name(), "[email protected]", false,false, message,
inviter, expiryDate,roleExpiryDate, Set.of(new InvitationRole(mail)));
guestInvitation.setEduIDOnly(true);
//To test graph callback
guestInvitation.setSubInvitee(GUEST_SUB);

Invitation graphInvitation =
new Invitation(Authority.GUEST, GRAPH_INVITATION_HASH, "[email protected]", false,false, message,
inviter,expiryDate, roleExpiryDate, Set.of(new InvitationRole(network)));
Expand Down
2 changes: 1 addition & 1 deletion server/src/test/java/access/api/UserControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void msAcceptReturn() throws Exception {
.get("/api/v1/users/ms-accept-return/{sub}")
.then()
.statusCode(302)
.header("Location", "http://localhost:4000");
.header("Location", "http://localhost:4000/proceed?hash=GUEST&isRedirect=true");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
package access.provision.graph;

import access.AbstractTest;
import access.manage.LocalManage;
import access.provision.Provisioning;
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.microsoft.graph.authentication.TokenCredentialAuthProvider;
import com.microsoft.graph.models.User;
import com.microsoft.graph.requests.GraphServiceClient;
import com.microsoft.graph.requests.UserRequest;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Map;

import static access.Seed.GUEST_SUB;
import static access.Seed.INVITER_SUB;
import static org.junit.jupiter.api.Assertions.*;

class GraphClientTest {
class GraphClientTest extends AbstractTest {

@Test
@Disabled
void newUserRequest() {
GraphClient graphClient = new GraphClient("http://localhost:8080", "test.eduid.nl");
LocalManage localManage = new LocalManage(new ObjectMapper(), true);
Expand Down

0 comments on commit db7060f

Please sign in to comment.