mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
fix translations
This commit is contained in:
@@ -63,7 +63,7 @@
|
|||||||
},
|
},
|
||||||
"userForm": {
|
"userForm": {
|
||||||
"subtitle": "Benutzer bearbeiten",
|
"subtitle": "Benutzer bearbeiten",
|
||||||
"userIsInternal": "Der Benutzer wird vom SCM-Manager verwaltet",
|
"userIsInternal": "Der Benutzer wird intern vom SCM-Manager verwaltet",
|
||||||
"userIsExternal": "Der Benutzer wird von einem externen System verwaltet",
|
"userIsExternal": "Der Benutzer wird von einem externen System verwaltet",
|
||||||
"button": {
|
"button": {
|
||||||
"submit": "Speichern",
|
"submit": "Speichern",
|
||||||
|
|||||||
@@ -63,12 +63,12 @@
|
|||||||
},
|
},
|
||||||
"userForm": {
|
"userForm": {
|
||||||
"subtitle": "Edit User",
|
"subtitle": "Edit User",
|
||||||
"userIsInternal": "This user is managed by SCM-Manager",
|
"userIsInternal": "This user is managed internally by SCM-Manager",
|
||||||
"userIsExternal": "This user is managed by an external system",
|
"userIsExternal": "This user is managed by an external system",
|
||||||
"button": {
|
"button": {
|
||||||
"submit": "Submit",
|
"submit": "Submit",
|
||||||
"convertToExternal": "Convert to external",
|
"convertToExternal": "Convert user to external",
|
||||||
"convertToInternal": "Convert to internal"
|
"convertToInternal": "Convert user to internal"
|
||||||
},
|
},
|
||||||
"modal": {
|
"modal": {
|
||||||
"passwordRequired": "Set new password for internal user",
|
"passwordRequired": "Set new password for internal user",
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import styled from "styled-components";
|
|||||||
const ExternalDescription = styled.div`
|
const ExternalDescription = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 1.25rem;
|
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@@ -179,6 +179,20 @@ class UserForm extends React.Component<Props, State> {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{!this.props.user && (
|
||||||
|
<>
|
||||||
|
<div className="columns">
|
||||||
|
<div className="column">
|
||||||
|
<Checkbox
|
||||||
|
label={t("user.externalFlag")}
|
||||||
|
onChange={this.handleExternalChange}
|
||||||
|
checked={!!user.external}
|
||||||
|
helpText={t("help.externalFlagHelpText")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{!user.external && (
|
{!user.external && (
|
||||||
<>
|
<>
|
||||||
{!this.props.user && passwordChangeField}
|
{!this.props.user && passwordChangeField}
|
||||||
@@ -249,6 +263,15 @@ class UserForm extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleExternalChange = (external: boolean) => {
|
||||||
|
this.setState({
|
||||||
|
user: {
|
||||||
|
...this.state.user,
|
||||||
|
external
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withTranslation("users")(UserForm);
|
export default withTranslation("users")(UserForm);
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ public class UserResource {
|
|||||||
))
|
))
|
||||||
@ApiResponse(responseCode = "500", description = "internal server error")
|
@ApiResponse(responseCode = "500", description = "internal server error")
|
||||||
public Response toExternal(@PathParam("id") String name) {
|
public Response toExternal(@PathParam("id") String name) {
|
||||||
userManager.overwritePassword(name, passwordService.encryptPassword(null));
|
userManager.overwritePassword(name, null);
|
||||||
UserDto dto = userToDtoMapper.map(userManager.get(name));
|
UserDto dto = userToDtoMapper.map(userManager.get(name));
|
||||||
dto.setExternal(true);
|
dto.setExternal(true);
|
||||||
adapter.update(name, existing -> dtoToUserMapper.map(dto, existing.getPassword()));
|
adapter.update(name, existing -> dtoToUserMapper.map(dto, existing.getPassword()));
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.github.sdorra.shiro.ShiroRule;
|
|||||||
import com.github.sdorra.shiro.SubjectAware;
|
import com.github.sdorra.shiro.SubjectAware;
|
||||||
import com.google.common.io.Resources;
|
import com.google.common.io.Resources;
|
||||||
import com.google.inject.util.Providers;
|
import com.google.inject.util.Providers;
|
||||||
|
import com.sun.mail.iap.Argument;
|
||||||
import org.apache.shiro.authc.credential.PasswordService;
|
import org.apache.shiro.authc.credential.PasswordService;
|
||||||
import org.jboss.resteasy.mock.MockHttpRequest;
|
import org.jboss.resteasy.mock.MockHttpRequest;
|
||||||
import org.jboss.resteasy.mock.MockHttpResponse;
|
import org.jboss.resteasy.mock.MockHttpResponse;
|
||||||
@@ -58,10 +59,12 @@ import java.util.Collection;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import static java.util.Collections.singletonList;
|
import static java.util.Collections.singletonList;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doNothing;
|
import static org.mockito.Mockito.doNothing;
|
||||||
import static org.mockito.Mockito.doThrow;
|
import static org.mockito.Mockito.doThrow;
|
||||||
@@ -457,6 +460,43 @@ public class UserRootResourceTest {
|
|||||||
assertEquals("other:*", captor.getValue().iterator().next().getValue());
|
assertEquals("other:*", captor.getValue().iterator().next().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldConvertUserToInternalAndSetNewPassword() throws URISyntaxException {
|
||||||
|
when(passwordService.encryptPassword(anyString())).thenReturn("abc");
|
||||||
|
ArgumentCaptor<User> userCaptor = ArgumentCaptor.forClass(User.class);
|
||||||
|
MockHttpRequest request = MockHttpRequest
|
||||||
|
.put("/" + UserRootResource.USERS_PATH_V2 + "Neo/convert-to-internal")
|
||||||
|
.contentType(VndMediaType.USER)
|
||||||
|
.content("{\"newPassword\":\"trillian\"}".getBytes());
|
||||||
|
MockHttpResponse response = new MockHttpResponse();
|
||||||
|
|
||||||
|
dispatcher.invoke(request, response);
|
||||||
|
|
||||||
|
verify(passwordService).encryptPassword("trillian");
|
||||||
|
verify(userManager).overwritePassword("Neo", "abc");
|
||||||
|
verify(userManager).modify(userCaptor.capture());
|
||||||
|
|
||||||
|
User user = userCaptor.getValue();
|
||||||
|
assertThat(user.isExternal()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldConvertUserToExternalAndRemoveLocalPassword() throws URISyntaxException {
|
||||||
|
ArgumentCaptor<User> userCaptor = ArgumentCaptor.forClass(User.class);
|
||||||
|
MockHttpRequest request = MockHttpRequest
|
||||||
|
.put("/" + UserRootResource.USERS_PATH_V2 + "Neo/convert-to-external")
|
||||||
|
.contentType(VndMediaType.USER);
|
||||||
|
MockHttpResponse response = new MockHttpResponse();
|
||||||
|
|
||||||
|
dispatcher.invoke(request, response);
|
||||||
|
|
||||||
|
verify(userManager).overwritePassword("Neo", null);
|
||||||
|
verify(userManager).modify(userCaptor.capture());
|
||||||
|
|
||||||
|
User user = userCaptor.getValue();
|
||||||
|
assertThat(user.isExternal()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
private PageResult<User> createSingletonPageResult(int overallCount) {
|
private PageResult<User> createSingletonPageResult(int overallCount) {
|
||||||
return new PageResult<>(singletonList(createDummyUser("Neo")), overallCount);
|
return new PageResult<>(singletonList(createDummyUser("Neo")), overallCount);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user