Skip to content

Commit 5ed46e5

Browse files
authored
Support client identifiers in session data structures (#1279)
1 parent 09b0a13 commit 5ed46e5

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

core/api/src/main/java/org/trellisldp/api/Session.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,18 @@ public interface Session {
4848
*
4949
* @return the user who delegated access
5050
*/
51-
Optional<IRI> getDelegatedBy();
51+
default Optional<IRI> getDelegatedBy() {
52+
return Optional.empty();
53+
}
54+
55+
/**
56+
* Get the client identifier, if one exists.
57+
*
58+
* @return the client identifier
59+
*/
60+
default Optional<String> getClientIdentifier() {
61+
return Optional.empty();
62+
}
5263

5364
/**
5465
* Get the date when the session was created.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2021 Aaron Coburn and individual contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.trellisldp.api;
17+
18+
import static org.junit.jupiter.api.Assertions.*;
19+
import static org.mockito.Mockito.*;
20+
21+
import org.junit.jupiter.api.Test;
22+
import org.junit.jupiter.api.extension.ExtendWith;
23+
import org.mockito.Mock;
24+
import org.mockito.junit.jupiter.MockitoExtension;
25+
26+
@ExtendWith(MockitoExtension.class)
27+
class SessionTest {
28+
29+
@Mock
30+
private Session mockSession;
31+
32+
@Test
33+
void testSession() {
34+
doCallRealMethod().when(mockSession).getDelegatedBy();
35+
doCallRealMethod().when(mockSession).getClientIdentifier();
36+
37+
assertFalse(mockSession.getDelegatedBy().isPresent());
38+
assertFalse(mockSession.getClientIdentifier().isPresent());
39+
}
40+
}

0 commit comments

Comments
 (0)