Skip to content

Commit 243300d

Browse files
committed
fixing auth
1 parent cad401e commit 243300d

2 files changed

Lines changed: 24 additions & 20 deletions

File tree

jdk_17_maven/em/embedded/rest/familie-ba-sak/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@
4343
<dependency>
4444
<groupId>no.nav.security</groupId>
4545
<artifactId>mock-oauth2-server</artifactId>
46-
<version>2.0.1</version>
46+
<version>2.1.4</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>com.fasterxml.jackson.module</groupId>
50+
<artifactId>jackson-module-kotlin</artifactId>
51+
<version>2.17.0</version>
4752
</dependency>
4853
</dependencies>
4954

jdk_17_maven/em/embedded/rest/familie-ba-sak/src/main/java/em/embedded/familie/ba/sak/EmbeddedEvoMasterController.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
import com.nimbusds.jose.JOSEObjectType;
44
import no.nav.security.mock.oauth2.MockOAuth2Server;
55
import no.nav.security.mock.oauth2.OAuth2Config;
6-
import no.nav.security.mock.oauth2.token.DefaultOAuth2TokenCallback;
76
import no.nav.security.mock.oauth2.token.RequestMapping;
87
import no.nav.security.mock.oauth2.token.RequestMappingTokenCallback;
9-
import org.evomaster.client.java.controller.AuthUtils;
108
import org.evomaster.client.java.controller.EmbeddedSutController;
119
import org.evomaster.client.java.controller.InstrumentedSutStarter;
1210
import org.evomaster.client.java.controller.api.dto.SutInfoDto;
@@ -115,41 +113,42 @@ public List<AuthenticationDto> getInfoForAuthentication() {
115113
);
116114
}
117115

118-
private RequestMappingTokenCallback getTokenCallback(String label, List<String> groups, String id, String name) {
116+
private RequestMapping getRequestMapping(String label, List<String> groups, String id, String name) {
119117
Map<String,Object> claims = new HashMap<>();
120118
claims.put("groups",groups);
121119
claims.put("name",name);
122120
claims.put("NAVident", id);
123121

124-
Set<RequestMapping> mappings = new HashSet<>();
125122
RequestMapping rm = new RequestMapping(TOKEN_PARAM,label,claims,JOSEObjectType.JWT.getType());
126-
mappings.add(rm);
123+
124+
return rm;
125+
}
126+
127+
private OAuth2Config getOAuth2Config(){
128+
129+
List<RequestMapping> mappings = Arrays.asList( getRequestMapping(A0, Arrays.asList(PROSESSERING_ROLLE),"Z0042", "Task Runner"),
130+
getRequestMapping(A1, Arrays.asList("VEILEDER"),"Z0000", "Mock McMockface"),
131+
getRequestMapping(A2, Arrays.asList("SAKSBEHANDLER"),"Z0001", "Foo Bar"),
132+
getRequestMapping(A3, Arrays.asList("BESLUTTER"),"Z0002", "John Smith"),
133+
getRequestMapping(A4, Arrays.asList("FORVALTER"),"Z0003", "Mario Rossi"),
134+
getRequestMapping(A5, Arrays.asList("KODE6"),"Z0004", "Kode Six"),
135+
getRequestMapping(A6, Arrays.asList("KODE7"),"Z0005", "Kode Seven"));
127136

128137
RequestMappingTokenCallback callback = new RequestMappingTokenCallback(
129138
ISSUER_ID,
130139
mappings,
131140
360000
132141
);
133142

134-
return callback;
135-
}
136-
137-
private OAuth2Config getOAuth2Config(){
138-
139143
Set<RequestMappingTokenCallback> callbacks = Set.of(
140-
getTokenCallback(A0, Arrays.asList(PROSESSERING_ROLLE),"Z0042", "Task Runner"),
141-
getTokenCallback(A1, Arrays.asList("VEILEDER"),"Z0000", "Mock McMockface"),
142-
getTokenCallback(A2, Arrays.asList("SAKSBEHANDLER"),"Z0001", "Foo Bar"),
143-
getTokenCallback(A3, Arrays.asList("BESLUTTER"),"Z0002", "John Smith"),
144-
getTokenCallback(A4, Arrays.asList("FORVALTER"),"Z0003", "Mario Rossi"),
145-
getTokenCallback(A5, Arrays.asList("KODE6"),"Z0004", "Kode Six"),
146-
getTokenCallback(A6, Arrays.asList("KODE7"),"Z0005", "Kode Seven")
144+
callback
147145
);
148146

149147
OAuth2Config config = new OAuth2Config(
150-
false,
148+
true,
151149
null,
152150
null,
151+
false,
153152
new no.nav.security.mock.oauth2.token.OAuth2TokenProvider(),
154153
callbacks
155154
);
@@ -164,7 +163,7 @@ private AuthenticationDto getAuthenticationDto(String label, String oauth2Url){
164163
dto.loginEndpointAuth = x;
165164

166165
x.externalEndpointURL = oauth2Url;
167-
x.payloadRaw = TOKEN_PARAM+"="+label+"&grant_type=authorization_code&code=foo&client_id=foo";
166+
x.payloadRaw = TOKEN_PARAM+"="+label+"&grant_type=client_credentials&code=foo&client_id=foo&client_secret=secret";
168167
x.verb = HttpVerb.POST;
169168
x.contentType = "application/x-www-form-urlencoded";
170169
x.expectCookies = false;

0 commit comments

Comments
 (0)