diff --git a/android-app/src/main/java/com/maptology/android/app/adapter/DetailViewHolder.java b/android-app/src/main/java/com/maptology/android/app/adapter/DetailViewHolder.java index 09a6d55..0950512 100644 --- a/android-app/src/main/java/com/maptology/android/app/adapter/DetailViewHolder.java +++ b/android-app/src/main/java/com/maptology/android/app/adapter/DetailViewHolder.java @@ -38,6 +38,7 @@ public class DetailViewHolder extends RecyclerView.ViewHolder { private View updatedLine; // the text fields to hold the content + private TextView nameText; private TextView updatedText; private TextView messageText; private TextView destinationText; @@ -71,6 +72,7 @@ public class DetailViewHolder extends RecyclerView.ViewHolder { updatedLine = v.findViewById(R.id.view_detail_updated_line); messageLine = v.findViewById(R.id.view_detail_message_line); destinationLine = v.findViewById(R.id.view_detail_destination_line); + nameText = (TextView)v.findViewById(R.id.view_detail_name); updatedText = (TextView) v.findViewById(R.id.view_detail_updated); messageText = (TextView) v.findViewById(R.id.view_detail_message); destinationText = (TextView) v.findViewById(R.id.view_detail_destination); @@ -100,6 +102,9 @@ public class DetailViewHolder extends RecyclerView.ViewHolder { */ public void setGrant(Grant grant) { ShareInfo info = grant.getInfo(); + String name = nameText.getResources().getString(R.string.share_name_none); + if (info != null && info.getName() != null) name = info.getName(); + setText(nameText, name, null); setText(tokenText, grant.getToken(), null); setText(messageText, (info == null ? null : info.getMessage()), messageLine); setText(destinationText, (info == null ? null : info.getDestination()), destinationLine); @@ -168,6 +173,7 @@ public class DetailViewHolder extends RecyclerView.ViewHolder { * @param share The share. */ public void setShare(LocalShare share) { + setText(nameText, nameText.getResources().getString(R.string.share_name_self), null); setText(tokenText, share.getToken(), null); setText(messageText, share.getMessage(), messageLine); setText(destinationText, share.getDestination(), destinationLine); diff --git a/android-app/src/main/java/com/maptology/android/app/fragment/MapFragment.java b/android-app/src/main/java/com/maptology/android/app/fragment/MapFragment.java index f46d577..7214a45 100644 --- a/android-app/src/main/java/com/maptology/android/app/fragment/MapFragment.java +++ b/android-app/src/main/java/com/maptology/android/app/fragment/MapFragment.java @@ -38,6 +38,7 @@ import android.support.annotation.Nullable; import android.support.design.widget.BottomSheetBehavior; import android.support.design.widget.FloatingActionButton; import android.support.v4.app.FragmentTransaction; +import android.support.v4.util.LongSparseArray; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -85,7 +86,7 @@ public class MapFragment extends AbstractFragment { /** * The grant markers that are currently displayed on the map. */ - private Map grantMarkers = new HashMap<>(); + private LongSparseArray grantMarkers = new LongSparseArray(); /** * The button to create a new share. @@ -375,7 +376,7 @@ public class MapFragment extends AbstractFragment { * Updates the map representation with the grants. */ public void updateGrants() { - Map markers = new HashMap<>(); + LongSparseArray markers = new LongSparseArray<>(); Long selection = getRepository().mapSelection.getValue(); MapMode mode = getRepository().mapMode.getValue(); MapState state = getRepository().mapState.getValue(); @@ -385,7 +386,8 @@ public class MapFragment extends AbstractFragment { if (cursor != null) { while (cursor.moveToNext()) { final Grant g = store.getGrant(cursor); - Marker m = grantMarkers.remove(g.getId()); + Marker m = grantMarkers.get(g.getId()); + grantMarkers.remove(g.getId()); if (g.getLocation() != null && g.getLocation().getCoordinate() != null) { Coordinate c = g.getLocation().getCoordinate(); coordinates.add(c); @@ -423,8 +425,8 @@ public class MapFragment extends AbstractFragment { } cursor.close(); } - for (Marker m: grantMarkers.values()) { - map.removeMarker(m); + for (int i = 0; i < grantMarkers.size(); i++) { + map.removeMarker(grantMarkers.valueAt(i)); } grantMarkers.clear(); grantMarkers.putAll(markers); diff --git a/android-app/src/main/java/com/maptology/android/app/fragment/TermsFragment.java b/android-app/src/main/java/com/maptology/android/app/fragment/TermsFragment.java index 4a99da6..9a0d03d 100644 --- a/android-app/src/main/java/com/maptology/android/app/fragment/TermsFragment.java +++ b/android-app/src/main/java/com/maptology/android/app/fragment/TermsFragment.java @@ -2,12 +2,14 @@ package com.maptology.android.app.fragment; import com.maptology.android.app.R; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.net.MailTo; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.support.annotation.Nullable; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -23,7 +25,7 @@ import android.widget.CheckBox; * @author sarah */ public class TermsFragment extends AbstractFragment { - + /** * The log tag for debugging. */ @@ -48,7 +50,13 @@ public class TermsFragment extends AbstractFragment { */ private WebView webView; - @Override + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @Override + @SuppressLint("SetJavaScriptEnabled") // its ok, we need it for the dsgvo viewer public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_terms, container, false); // load the license terms from the assets folder diff --git a/android-app/src/main/res/drawable/ic_vpn_key_black_24dp.xml b/android-app/src/main/res/drawable/ic_vpn_key_black_24dp.xml new file mode 100644 index 0000000..2eddd16 --- /dev/null +++ b/android-app/src/main/res/drawable/ic_vpn_key_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/android-app/src/main/res/layout/fragment_map.xml b/android-app/src/main/res/layout/fragment_map.xml index 3c06f1f..b6d9e00 100644 --- a/android-app/src/main/res/layout/fragment_map.xml +++ b/android-app/src/main/res/layout/fragment_map.xml @@ -15,7 +15,7 @@ android:id="@+id/map" android:layout_weight="1" android:layout_width="match_parent" - android:layout_height="wrap_content"/> + android:layout_height="0dp"/> @@ -50,15 +52,16 @@ android:id="@+id/view_detail_creation_label" android:textAppearance="?android:attr/textAppearanceSmall" android:text="@string/share_creation_time" - android:layout_width="wrap_content" android:layout_height="wrap_content"/> @@ -76,8 +79,10 @@ android:id="@+id/view_detail_expiration_time" android:textAppearance="?android:attr/textAppearanceSmall" tools:text="12/12/12 10:30" + android:paddingLeft="4dp" + android:paddingStart="4dp" android:layout_weight="1" - android:gravity="end" + android:gravity="start" android:layout_width="0dp" android:layout_height="wrap_content"/> @@ -183,4 +188,28 @@ android:layout_weight="1"/> + + + + + + + \ No newline at end of file diff --git a/android-app/src/main/res/values-de/strings.xml b/android-app/src/main/res/values-de/strings.xml index b5f0d0a..2b3f4b5 100644 --- a/android-app/src/main/res/values-de/strings.xml +++ b/android-app/src/main/res/values-de/strings.xml @@ -52,10 +52,13 @@ Standortfreigabe ändern Nachricht Zielort - Hinzugefügt am: - Erstellt am: - Gültig bis: - Schlüssel: + Hinzugefügt am + Erstellt am + Ablauf am + Freigegeben von + einem anonymen Nutzer + Dir + Schlüssel Freigabedaten Zuletzt aktualisiert Halte die Freigabe an, um Deinen Standort zu verbergen, ohne die Freigabe zu löschen diff --git a/android-app/src/main/res/values/strings.xml b/android-app/src/main/res/values/strings.xml index 3f275bb..3374de6 100644 --- a/android-app/src/main/res/values/strings.xml +++ b/android-app/src/main/res/values/strings.xml @@ -56,8 +56,11 @@ Message Destination Added on: - Created on: - Expires on: + Create on + Expires on + Shared by + an anonymous user + you Identifier: Location status Last update diff --git a/android-feign/src/main/java/com/maptology/android/feign/ApiClient.java b/android-feign/src/main/java/com/maptology/android/feign/ApiClient.java index d7fd637..fd4a069 100644 --- a/android-feign/src/main/java/com/maptology/android/feign/ApiClient.java +++ b/android-feign/src/main/java/com/maptology/android/feign/ApiClient.java @@ -121,7 +121,6 @@ public class ApiClient { objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); objectMapper.disable(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); - objectMapper.setDateFormat(new RFC3339DateFormat()); objectMapper.registerModule(new JodaModule()); return objectMapper; } diff --git a/android-feign/src/main/java/com/maptology/android/feign/ParamExpander.java b/android-feign/src/main/java/com/maptology/android/feign/ParamExpander.java deleted file mode 100644 index 7f65a97..0000000 --- a/android-feign/src/main/java/com/maptology/android/feign/ParamExpander.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.maptology.android.feign; - -import feign.Param; - -import java.text.DateFormat; -import java.util.Date; - -/** - * Param Expander to convert {@link Date} to RFC3339 - */ -public class ParamExpander implements Param.Expander { - - private static final DateFormat dateformat = new RFC3339DateFormat(); - - @Override - public String expand(Object value) { - if (value instanceof Date) { - return dateformat.format(value); - } - return value.toString(); - } -} diff --git a/android-feign/src/main/java/com/maptology/android/feign/RFC3339DateFormat.java b/android-feign/src/main/java/com/maptology/android/feign/RFC3339DateFormat.java deleted file mode 100644 index 8078114..0000000 --- a/android-feign/src/main/java/com/maptology/android/feign/RFC3339DateFormat.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Maptology Service - * Maptology Service - * - * OpenAPI spec version: 0.0.1-SNAPSHOT - * Contact: nes-admin@uni-due.de - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package com.maptology.android.feign; - -import com.fasterxml.jackson.databind.util.ISO8601DateFormat; -import com.fasterxml.jackson.databind.util.ISO8601Utils; - -import java.text.FieldPosition; -import java.util.Date; - -@SuppressWarnings("deprecation") -public class RFC3339DateFormat extends ISO8601DateFormat { - - private static final long serialVersionUID = 2091364120558567279L; - -// Same as ISO8601DateFormat but serializing milliseconds. - @Override - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - String value = ISO8601Utils.format(date, true); - toAppendTo.append(value); - return toAppendTo; - } - -} \ No newline at end of file diff --git a/service-ejb/src/test/java/com/maptology/service/test/login/LoginModule.java b/service-ejb/src/test/java/com/maptology/service/test/login/LoginModule.java index ad2fbf5..15bb0e6 100644 --- a/service-ejb/src/test/java/com/maptology/service/test/login/LoginModule.java +++ b/service-ejb/src/test/java/com/maptology/service/test/login/LoginModule.java @@ -32,6 +32,7 @@ import com.maptology.service.principal.MaptologyPrincipal; * * @author Marcus */ +@SuppressWarnings("deprecation") public class LoginModule extends UsernamePasswordLoginModule { /** diff --git a/service-war/src/test/java/com/maptology/service/test/rest/DeviceResourceTest.java b/service-war/src/test/java/com/maptology/service/test/rest/DeviceResourceTest.java index d82dfc8..9ec270c 100644 --- a/service-war/src/test/java/com/maptology/service/test/rest/DeviceResourceTest.java +++ b/service-war/src/test/java/com/maptology/service/test/rest/DeviceResourceTest.java @@ -61,21 +61,18 @@ public class DeviceResourceTest extends AbstractResourceTest { } @Test - public void createDevice_AsAnonymous() { + public void createDeviceAsAnonymous() { Response r = anonProxy.createDevice(createValidDeviceInfo()); - AssertResponse.isStatus(r, Status.CREATED); AssertResponse.hasHeader(r, "Content-Location"); - DeviceHandle d = AssertResponse.hasBodyOfType(r, DeviceHandle.class); Assert.assertTrue("Response should contain id.", d.getId() > 0); Assert.assertNull("Response should not contain user login.", d.getUser()); } @Test - public void createDevice_AsUser() { + public void createDeviceAsUser() { Response r = userProxy.createDevice(createValidDeviceInfo()); - AssertResponse.isStatus(r, Status.CREATED); DeviceHandle d = AssertResponse.hasBodyOfType(r, DeviceHandle.class); Long userId = getUserProxyUserId(); @@ -83,42 +80,38 @@ public class DeviceResourceTest extends AbstractResourceTest { } @Test - public void createDevice_AsAdmin() { + public void createDeviceAsAdmin() { Response r = adminProxy.createDevice(createValidDeviceInfo()); - AssertResponse.isStatus(r, Status.CREATED); } @Test - public void createDevice_AsDevice() { + public void createDeviceAsDevice() { Response r = deviceProxy.createDevice(createValidDeviceInfo()); - AssertResponse.isStatus(r, Status.CREATED); } @Test - public void getDevices_AsAnonymous() { + public void getDevicesAsAnonymous() { AssertResponse.isForbidden(anonProxy.getDevices(new PageConfig(0, 5))); } @Test - public void getDevices_AsUser() { + public void getDevicesAsUser() { AssertResponse.isForbidden(userProxy.getDevices(new PageConfig(0, 5))); } @Test - public void getDevices_AsDevice() { + public void getDevicesAsDevice() { AssertResponse.isForbidden(deviceProxy.getDevices(new PageConfig(0, 5))); } @Test - public void getDevices_AsAdmin() { + public void getDevicesAsAdmin() { // prepare long addedId = registerTestDevice().getId(); - // test Response r = adminProxy.getDevices(new PageConfig(0, 100)); // use size 100 to ensure device is included - // assert AssertResponse.isStatus(r, Status.OK); DevicePage page = AssertResponse.hasBodyOfType(r, DevicePage.class); @@ -127,75 +120,66 @@ public class DeviceResourceTest extends AbstractResourceTest { } @Test - public void getDevice_AsAnonymous() { + public void getDeviceAsAnonymous() { long addedId = registerTestDevice().getId(); - AssertResponse.isForbidden(anonProxy.getDevice(addedId)); } @Test - public void getDevice_AsUser() { + public void getDeviceAsUser() { long addedId = registerTestDevice().getId(); - AssertResponse.isForbidden(userProxy.getDevice(addedId)); } @Test - public void getDevice_AsAdmin() { + public void getDeviceAsAdmin() { // prepare long addedId = registerTestDevice().getId(); - // test Response r = adminProxy.getDevice(addedId); - AssertResponse.isStatus(r, Status.OK); Device d = AssertResponse.hasBodyOfType(r, Device.class); Assert.assertNull("Should not be owned by any user.", d.getUser()); } @Test - public void getDevice_AsDevice() { + public void getDeviceAsDevice() { long addedId = registerTestDevice().getId(); - AssertResponse.isForbidden(deviceProxy.getDevice(addedId)); } @Test - public void getDevice_AsUser_WithOwnDevice() { + public void getDeviceAsUserWithOwnDevice() { DeviceHandle d = userProxy.createDevice(createValidDeviceInfo()).readEntity(DeviceHandle.class); - Response r = userProxy.getDevice(d.getId()); - AssertResponse.isStatus(r, Status.OK); } @Test - public void getDevice_AsDevice_WithOwnDevice() { + public void getDeviceAsDeviceWithOwnDevice() { DeviceHandle d = deviceProxy.createDevice(createValidDeviceInfo()).readEntity(DeviceHandle.class); - AssertResponse.isForbidden(userProxy.getDevice(d.getId())); } @Test - public void deleteCurrentDevice_AsAnonymous() { + public void deleteCurrentDeviceAsAnonymous() { AssertResponse.isForbidden(anonProxy.deleteCurrentDevice()); } @Test - public void deleteCurrentDevice_AsUser() { + public void deleteCurrentDeviceAsUser() { AssertResponse.isForbidden(userProxy.deleteCurrentDevice()); } @Test - public void deleteCurrentDevice_AsAdmin() { + public void deleteCurrentDeviceAsAdmin() { AssertResponse.isForbidden(adminProxy.deleteCurrentDevice()); } @Test - public void deleteCurrentDevice_AsDevice() { + public void deleteCurrentDeviceAsDevice() { DeviceHandle d = registerTestDevice(); Response r = getTarget(d.getToken()).proxy(IDeviceService.class).deleteCurrentDevice(); - AssertResponse.isStatus(r, Status.OK); String body = r.readEntity(String.class); Assert.assertTrue("Response body should be empty.", body.isEmpty()); @@ -204,26 +188,22 @@ public class DeviceResourceTest extends AbstractResourceTest { } @Test - public void deleteDevice_AsAnonymous() { + public void deleteDeviceAsAnonymous() { DeviceHandle addedDevice = registerTestDevice(); - AssertResponse.isForbidden(anonProxy.deleteDevice(addedDevice.getId())); } @Test - public void deleteDevice_AsUser() { + public void deleteDeviceAsUser() { DeviceHandle addedDevice = registerTestDevice(); - AssertResponse.isForbidden(userProxy.deleteDevice(addedDevice.getId())); } @Test - public void deleteDevice_AsUser_WithOwnDevice() { + public void deleteDeviceAsUserWithOwnDevice() { // test deleting own device with user auth DeviceHandle device = userProxy.createDevice(createValidDeviceInfo()).readEntity(DeviceHandle.class); - Response r = userProxy.deleteDevice(device.getId()); - AssertResponse.isStatus(r, Status.OK); Device deviceAsAdmin = adminProxy.getDevice(device.getId()).readEntity(Device.class); Assert.assertTrue("Device should be set to deleted.", deviceAsAdmin.isDeleted()); @@ -231,28 +211,24 @@ public class DeviceResourceTest extends AbstractResourceTest { } @Test - public void deleteDevice_AsDevice() { + public void deleteDeviceAsDevice() { Long addedId = registerTestDevice().getId(); - AssertResponse.isForbidden(deviceProxy.deleteDevice(addedId)); } @Test - public void deleteDevice_AsDevice_WithOwnDevice() { + public void deleteDeviceAsDeviceWithOwnDevice() { // test deleting own device with device auth DeviceHandle device = registerTestDevice(); - AssertResponse.isForbidden(getTarget(device.getToken()).proxy(IDeviceService.class).deleteDevice(device.getId())); } @Test - public void deleteDevice_AsAdmin() { + public void deleteDeviceAsAdmin() { // prepare DeviceHandle addedDevice = registerTestDevice(); - // deleting other device as admin Response r = adminProxy.deleteDevice(addedDevice.getId()); - AssertResponse.isStatus(r, Status.OK); String body = r.readEntity(String.class); Assert.assertTrue("Response body should be empty.", body.isEmpty()); @@ -261,109 +237,98 @@ public class DeviceResourceTest extends AbstractResourceTest { } @Test - public void getCurrentDevice_AsAnonymous() { + public void getCurrentDeviceAsAnonymous() { AssertResponse.isForbidden(anonProxy.getCurrentDevice()); } @Test - public void getCurrentDevice_AsUser() { + public void getCurrentDeviceAsUser() { AssertResponse.isForbidden(userProxy.getCurrentDevice()); } @Test - public void getCurrentDevice_AsAdmin() { + public void getCurrentDeviceAsAdmin() { AssertResponse.isForbidden(adminProxy.getCurrentDevice()); } @Test - public void getCurrentDevice_AsDevice() { + public void getCurrentDeviceAsDevice() { Response r = deviceProxy.getCurrentDevice(); - AssertResponse.isStatus(r, Status.OK); AssertResponse.hasBodyOfType(r, Device.class); } @Test - public void getCurrentUserDevices_AsAnonymous() { + public void getCurrentUserDevicesAsAnonymous() { AssertResponse.isForbidden(anonProxy.getCurrentUserDevices(new PageConfig(0, 5))); } @Test - public void getCurrentUserDevices_AsDevice() { + public void getCurrentUserDevicesAsDevice() { AssertResponse.isForbidden(deviceProxy.getCurrentUserDevices(new PageConfig(0, 5))); } @Test - public void getCurrentUserDevices_AsUser() { + public void getCurrentUserDevicesAsUser() { Response r = userProxy.getCurrentUserDevices(new PageConfig(0, 5)); AssertResponse.isStatus(r, Status.OK); AssertResponse.hasBodyOfType(r, DevicePage.class); } @Test - public void getCurrentUserDevices_AsAdmin() { + public void getCurrentUserDevicesAsAdmin() { Response r = adminProxy.getCurrentUserDevices(new PageConfig(0, 5)); - AssertResponse.isStatus(r, Status.OK); } @Test - public void setDevice_AsAnonymous() { + public void setDeviceAsAnonymous() { long addedId = registerTestDevice().getId(); - AssertResponse.isForbidden(anonProxy.setDevice(addedId, new Device())); } @Test - public void setDevice_AsUser() { + public void setDeviceAsUser() { // no access with user auth, for other devices long addedId = registerTestDevice().getId(); - AssertResponse.isForbidden(userProxy.setDevice(addedId, new Device())); } @Test - public void setDevice_AsUser_WithOwnDevice() { + public void setDeviceAsUserWithOwnDevice() { // no access with user auth, for own devices DeviceHandle ownDevice = userProxy.createDevice(createValidDeviceInfo()).readEntity(DeviceHandle.class); - AssertResponse.isForbidden(userProxy.setDevice(ownDevice.getId(), new Device())); } @Test - public void setDevice_AsDevice() { + public void setDeviceAsDevice() { // no access with device auth, for other devices long addedId = registerTestDevice().getId(); - AssertResponse.isForbidden(deviceProxy.setDevice(addedId, new Device())); } @Test - public void setDevice_AsDevice_WithOwnDevice() { + public void setDeviceAsDeviceWithOwnDevice() { // no access with device auth, for own devices DeviceHandle ownDevice = registerTestDevice(); - Response r = getTarget(ownDevice.getToken()).proxy(IDeviceService.class) .setDevice(ownDevice.getId(), new Device()); - AssertResponse.isStatus(r, Status.FORBIDDEN); } @Test - public void setDevice_AsAdmin() { + public void setDeviceAsAdmin() { // prepare Long validUserId = getUserProxyUserId(); long addedId = registerTestDevice().getId(); - Device update = new Device(); update.setDevice("Peters iPhone"); update.setManufacturer("Apple"); update.setModel("iPhone 8"); update.setOs(OperatingSystem.IOS); update.setUser(validUserId); - Response r = adminProxy.setDevice(addedId, update); - AssertResponse.isStatus(r, Status.OK); Device d = AssertResponse.hasBodyOfType(r, Device.class); Assert.assertEquals("User should have changed.", update.getUser(), d.getUser()); diff --git a/service-war/src/test/java/com/maptology/service/test/rest/UserResourceTest.java b/service-war/src/test/java/com/maptology/service/test/rest/UserResourceTest.java index 36d1893..bb4f45e 100644 --- a/service-war/src/test/java/com/maptology/service/test/rest/UserResourceTest.java +++ b/service-war/src/test/java/com/maptology/service/test/rest/UserResourceTest.java @@ -91,34 +91,32 @@ public class UserResourceTest extends AbstractResourceTest { @Test - public void getCurrentUser_AsAnonymous() { + public void getCurrentUserAsAnonymous() { AssertResponse.isForbidden(anonProxy.getCurrentUser()); } @Test - public void getCurrentUser_AsUser() { + public void getCurrentUserAsUser() { Response r = userProxy.getCurrentUser(); - AssertResponse.isStatus(r, Status.OK); User user = AssertResponse.hasBodyOfType(r, User.class); Assert.assertEquals("User should be current user.", this.user.getId(), user.getId()); } @Test - public void getCurrentUser_AsAdmin() { + public void getCurrentUserAsAdmin() { Response r = adminProxy.getCurrentUser(); - AssertResponse.isStatus(r, Status.OK); AssertResponse.hasBodyOfType(r, User.class); } @Test - public void getCurrentUser_AsDevice() { + public void getCurrentUserAsDevice() { AssertResponse.isForbidden(deviceProxy.getCurrentUser()); } @Test - public void setCurrentUser_AsAnonymous() { + public void setCurrentUserAsAnonymous() { AssertResponse.isForbidden(anonProxy.setCurrentUser(new User())); } @@ -126,51 +124,44 @@ public class UserResourceTest extends AbstractResourceTest { // TODO test parallel modification conflict // TODO test email modification (sending verification mails, setting correspondence correctly (and only once), removing single & multiple mail, dont allow removing correspondence, adding and removing simultaneously (incl. changing correspondence) @Test - public void setCurrentUser_AsUser() { + public void setCurrentUserAsUser() { // Set same user Response r = userProxy.setCurrentUser(user); - AssertResponse.isStatus(r, Status.OK); AssertResponse.hasBodyOfType(r, User.class); } @Test - public void setCurrentUser_AsAdmin() { + public void setCurrentUserAsAdmin() { // Set same user Response r = adminProxy.setCurrentUser(admin); - AssertResponse.isStatus(r, Status.OK); AssertResponse.hasBodyOfType(r, User.class); } @Test - public void setCurrentUser_AsDevice() { + public void setCurrentUserAsDevice() { AssertResponse.isForbidden(deviceProxy.setCurrentUser(new User())); } @Test - public void setCurrentPassword_AsAnonymous() { + public void setCurrentPasswordAsAnonymous() { UserPassword p = new UserPassword(); p.setPassword("newsecure"); - AssertResponse.isForbidden(anonProxy.setCurrentPassword(p)); } // TODO test password validation rules // TODO test parallel modification conflict @Test - public void setCurrentPassword_AsUser() { + public void setCurrentPasswordAsUser() { UserPassword p = new UserPassword(); p.setPassword("newsecure"); - Response r = userProxy.setCurrentPassword(p); - AssertResponse.isStatus(r, Status.OK); AssertResponse.hasBodyOfType(r, User.class); - // try old pw (now invalid) AssertResponse.isForbidden(userProxy.getCurrentUser()); - // reset pw for other tests UserPassword oldPW = new UserPassword(); oldPW.setPassword(userPassword); @@ -179,20 +170,19 @@ public class UserResourceTest extends AbstractResourceTest { } @Test - public void setCurrentPassword_AsDevice() { + public void setCurrentPasswordAsDevice() { UserPassword p = new UserPassword(); p.setPassword("somePassword"); - AssertResponse.isForbidden(deviceProxy.setCurrentPassword(p)); } @Test - public void addUser_AsAnonymous() { + public void addUserAsAnonymous() { AssertResponse.isForbidden(anonProxy.addUser(new User())); } @Test - public void addUser_AsUser() { + public void addUserAsUser() { AssertResponse.isForbidden(userProxy.addUser(new User())); } @@ -200,60 +190,57 @@ public class UserResourceTest extends AbstractResourceTest { // TODO test parallel modification conflict // TODO test email modification (sending verification email) @Test - public void addUser_AsAdmin() { + public void addUserAsAdmin() { Response r = adminProxy.addUser(createValidUser()); - AssertResponse.isStatus(r, Status.CREATED); AssertResponse.hasBodyOfType(r, User.class); } @Test - public void addUser_AsDevice() { + public void addUserAsDevice() { AssertResponse.isForbidden(deviceProxy.addUser(new User())); } @Test - public void getUser_AsAnonymous() { + public void getUserAsAnonymous() { AssertResponse.isForbidden(anonProxy.getUser(user.getId())); } @Test - public void getUser_AsUser() { + public void getUserAsUser() { AssertResponse.isForbidden(userProxy.getUser(admin.getId())); } @Test - public void getUser_AsUser_WithOwnId() { + public void getUserAsUserWithOwnId() { AssertResponse.isForbidden(userProxy.getUser(user.getId())); } @Test - public void getUser_AsAdmin() { + public void getUserAsAdmin() { Response r = adminProxy.getUser(user.getId()); - AssertResponse.isStatus(r, Status.OK); User u = AssertResponse.hasBodyOfType(r, User.class); - Assert.assertEquals("Should return correct user.", user.getLogin(), u.getLogin()); } @Test - public void getUser_AsDevice() { + public void getUserAsDevice() { AssertResponse.isForbidden(deviceProxy.getUser(user.getId())); } @Test - public void setUser_AsAnonymous() { + public void setUserAsAnonymous() { AssertResponse.isForbidden(anonProxy.setUser(user.getId(), user)); } @Test - public void setUser_AsUser() { + public void setUserAsUser() { AssertResponse.isForbidden(userProxy.setUser(admin.getId(), user)); } @Test - public void setUser_AsUser_WithOwnId() { + public void setUserAsUserWithOwnId() { AssertResponse.isForbidden(userProxy.setUser(user.getId(), user)); } @@ -261,47 +248,42 @@ public class UserResourceTest extends AbstractResourceTest { // TODO test parallel modification conflict // TODO test email modification (see setCurrentUser()) @Test - public void setUser_AsAdmin() { + public void setUserAsAdmin() { Response r = adminProxy.setUser(user.getId(), user); - AssertResponse.isStatus(r, Status.OK); AssertResponse.hasBodyOfType(r, User.class); } @Test - public void setUser_AsDevice() { + public void setUserAsDevice() { AssertResponse.isForbidden(deviceProxy.setUser(user.getId(), user)); } @Test - public void setUserPassword_AsAnonymous() { + public void setUserPasswordAsAnonymous() { AssertResponse.isForbidden(anonProxy.setUserPassword(user.getId(), new UserPassword())); } @Test - public void setUserPassword_AsUser() { + public void setUserPasswordAsUser() { AssertResponse.isForbidden(userProxy.setUserPassword(admin.getId(), new UserPassword())); } @Test - public void setUserPassword_AsUser_WithOwnId() { + public void setUserPasswordAsUserWithOwnId() { AssertResponse.isForbidden(userProxy.setUserPassword(user.getId(), new UserPassword())); } // TODO test parallel modification conflict @Test - public void setUserPassword_AsAdmin() { + public void setUserPasswordAsAdmin() { UserPassword p = new UserPassword(); p.setPassword("newsecure"); - Response r = adminProxy.setUserPassword(user.getId(), p); - AssertResponse.isStatus(r, Status.OK); AssertResponse.hasBodyOfType(r, User.class); - // try old pw (now invalid) AssertResponse.isForbidden(userProxy.getCurrentUser()); - // reset pw for other tests UserPassword oldPW = new UserPassword(); oldPW.setPassword(userPassword); @@ -310,60 +292,56 @@ public class UserResourceTest extends AbstractResourceTest { } @Test - public void setUserPassword_AsDevice() { + public void setUserPasswordAsDevice() { AssertResponse.isForbidden(deviceProxy.setUserPassword(user.getId(), new UserPassword())); } @Test - public void getUsers_AsAnonymous() { + public void getUsersAsAnonymous() { AssertResponse.isForbidden(anonProxy.getUsers(new PageConfig(0, 5))); } @Test - public void getUsers_AsUser() { + public void getUsersAsUser() { AssertResponse.isForbidden(userProxy.getUsers(new PageConfig(0, 5))); } @Test - public void getUsers_AsAdmin() { + public void getUsersAsAdmin() { Response r = adminProxy.getUsers(new PageConfig(0, 50)); - AssertResponse.isStatus(r, Status.OK); UserPage page = AssertResponse.hasBodyOfType(r, UserPage.class); - boolean contains = page.getElements().stream().anyMatch(u -> u.getId() == admin.getId()); Assert.assertTrue("Should contain user \"admin\".", contains); } @Test - public void getUsers_AsDevice() { + public void getUsersAsDevice() { AssertResponse.isForbidden(deviceProxy.getUsers(new PageConfig(0, 5))); } @Test - public void searchUsers_AsAnonymous() { + public void searchUsersAsAnonymous() { AssertResponse.isForbidden(anonProxy.searchUsers(new PageConfig(0, 5), "term")); } @Test - public void searchUsers_AsUser() { + public void searchUsersAsUser() { AssertResponse.isForbidden( userProxy.searchUsers(new PageConfig(0, 5), "term")); } @Test - public void searchUsers_AsAdmin() { + public void searchUsersAsAdmin() { Response r = adminProxy.searchUsers(new PageConfig(0, 100), user.getLogin()); - AssertResponse.isStatus(r, Status.OK); UserPage page = AssertResponse.hasBodyOfType(r, UserPage.class); - boolean contains = page.getElements().stream().anyMatch(u -> u.getId() == user.getId()); Assert.assertTrue("Should contain user " + user.getLogin() + ".", contains); } @Test - public void searchUsers_AsDevice() { + public void searchUsersAsDevice() { AssertResponse.isForbidden( deviceProxy.searchUsers(new PageConfig(0, 5), "term")); } @@ -372,56 +350,48 @@ public class UserResourceTest extends AbstractResourceTest { // TODO test email set to not verified & correspondence // TODO test email verification sent @Test - public void registerUser_AsAnonymous() { + public void registerUserAsAnonymous() { Response r = anonProxy.registerUser(createValidUserRegistration()); - AssertResponse.isStatus(r, Status.OK); } @Test - public void registerUser_AsAnonymous_WithAlreadyExistingLogin() { + public void registerUserAsAnonymousWithAlreadyExistingLogin() { UserRegistration reg = new UserRegistration( user.getLogin(), "somepassword", "test name", "somemail@example.com"); - Response r = anonProxy.registerUser(reg); - AssertResponse.isStatus(r, Status.CONFLICT); } @Test - public void registerUser_AsAnonymous_WithAlreadyExistingMail() { + public void registerUserAsAnonymousWithAlreadyExistingMail() { UserRegistration reg = new UserRegistration( "testuser", "somepassword", "test name", user.getEmails().get(0).getAddress()); - Response r = anonProxy.registerUser(reg); - AssertResponse.isStatus(r, Status.OK); } @Test - public void registerUser_AsUser() { + public void registerUserAsUser() { Response r = userProxy.registerUser(createValidUserRegistration()); - AssertResponse.isStatus(r, Status.OK); } @Test - public void registerUser_AsAdmin() { + public void registerUserAsAdmin() { Response r = adminProxy.registerUser(createValidUserRegistration()); - AssertResponse.isStatus(r, Status.OK); } @Test - public void registerUser_AsDevice() { + public void registerUserAsDevice() { Response r = deviceProxy.registerUser(createValidUserRegistration()); - AssertResponse.isStatus(r, Status.OK); } @@ -429,47 +399,40 @@ public class UserResourceTest extends AbstractResourceTest { // TODO actual email (token) also needed to test resetUserPassword() // TODO test valid user with no verified email @Test - public void resetUser_AsAnonymous() { + public void resetUserAsAnonymous() { int nextEntryIndex = emailSession.getEntries().size(); // create test user UserRegistration user = createValidUserRegistration(); AssertResponse.isStatus(anonProxy.registerUser(user), Status.OK); - Response r = anonProxy.resetUser(user.getLogin()); - AssertResponse.isStatus(r, Status.NO_CONTENT); IDebugEmailSessionBean.EmailEntry entry = emailSession.getEntries().get(nextEntryIndex); Assert.assertEquals("Email should be sent to correspondence address.", user.getEmail(), entry.getReceiver()); } @Test - public void resetUser_AsAnonymous_WithInvalidUserLogin() { + public void resetUserAsAnonymousWithInvalidUserLogin() { int previousSize = emailSession.getEntries().size(); - Response r = anonProxy.resetUser("nonexistinglogin"); - AssertResponse.isStatus(r, Status.NOT_FOUND); Assert.assertEquals("Should not have sent an email.", previousSize, emailSession.getEntries().size()); } @Test - public void resetUser_AsUser() { + public void resetUserAsUser() { Response r = userProxy.resetUser(user.getLogin()); - AssertResponse.isStatus(r, Status.NO_CONTENT); } @Test - public void resetUser_AsAdmin() { + public void resetUserAsAdmin() { Response r = adminProxy.resetUser(user.getLogin()); - AssertResponse.isStatus(r, Status.NO_CONTENT); } @Test - public void resetUser_AsDevice() { + public void resetUserAsDevice() { Response r = deviceProxy.resetUser(user.getLogin()); - AssertResponse.isStatus(r, Status.NO_CONTENT); } @@ -486,9 +449,7 @@ public class UserResourceTest extends AbstractResourceTest { nextEntryIndex = emailSession.getEntries().size(); AssertResponse.isStatus(anonProxy.resetUser(user.getLogin()), Status.NO_CONTENT); String token = emailSession.getEntries().get(nextEntryIndex).getVariableToken(); - Response r = anonProxy.resetUserPassword(token, new UserPassword("newPassword")); - AssertResponse.isStatus(r, Status.OK); AssertResponse.hasBodyOfType(r, User.class); // can authenticate with new password diff --git a/web-angular/src/app/services/export.service.ts b/web-angular/src/app/services/export.service.ts index fd937d3..5f96bd7 100644 --- a/web-angular/src/app/services/export.service.ts +++ b/web-angular/src/app/services/export.service.ts @@ -17,7 +17,6 @@ export class ExportService { private static readonly COLUMN_SEPARATOR = ';'; private static readonly LINE_SEPARATOR = '\r\n'; - downloading = new BehaviorSubject(false); error = new BehaviorSubject(false); devices = new BehaviorSubject(ExportService.emptyPage()); diff --git a/web-angular/src/app/services/resource.service.ts b/web-angular/src/app/services/resource.service.ts index b4085af..8e2c9ac 100644 --- a/web-angular/src/app/services/resource.service.ts +++ b/web-angular/src/app/services/resource.service.ts @@ -87,7 +87,8 @@ export class ResourceService { 'share_dialog_placeholder': 'Freigabelink', 'share_dialog_success': 'Die Freigabe wurde erfolgreich hinzugefügt.', 'share_dialog_error': 'Die Freigabe konnte nicht erstellt werden. Hast Du den Freigabelink vollständig eingegeben?', - 'tile_map_attribution': 'Kartendaten: © OpenStreetMap | Visualisierung: © Locoslab GmbH', + 'tile_map_attribution': 'Kartendaten: © OpenStreetMap ' + + '| Visualisierung: © Locoslab GmbH', // views 'export_title' : 'Export', 'export_explain_title' : 'Daten exportieren', @@ -184,7 +185,8 @@ export class ResourceService { 'privileges_title': 'Freigaben', 'privileges_add_tooltip': 'Freigabe hinzufügen', 'privileges_id': 'ID', - 'privileges_name' : "Name", + 'privileges_name' : 'Name', + 'privileges_nobody' : 'Anonymer Nutzer', 'privileges_token': 'Schlüssel', 'privileges_creation': 'Erstellung', 'privileges_message': 'Nachricht', @@ -507,7 +509,8 @@ export class ResourceService { 'share_dialog_placeholder': 'Sharing link', 'share_dialog_success': 'The share was added successfully.', 'share_dialog_error': 'Unable to add the sharing link. Did you type it in correctly?', - 'tile_map_attribution': 'Map data: © OpenStreetMap | Visualization: © Locoslab GmbH', + 'tile_map_attribution': 'Map data: © OpenStreetMap ' + + '| Visualization: © Locoslab GmbH', // views 'export_title' : 'Export', 'export_explain_title' : 'Export data', @@ -601,6 +604,7 @@ export class ResourceService { 'privileges_add_tooltip': 'Add share', 'privileges_id': 'ID', 'privileges_name' : 'Name', + 'privileges_nobody' : 'Anonymous User', 'privileges_token': 'Key', 'privileges_creation': 'Creation', 'privileges_message': 'Message', diff --git a/web-angular/src/app/views/privileges.component.html b/web-angular/src/app/views/privileges.component.html index d16bb52..0cf3fc3 100644 --- a/web-angular/src/app/views/privileges.component.html +++ b/web-angular/src/app/views/privileges.component.html @@ -22,7 +22,7 @@ {{ res.strings('privileges_name') }} - {{ element.shareInfo.name }} + {{ getName(element) }} diff --git a/web-angular/src/app/views/privileges.component.ts b/web-angular/src/app/views/privileges.component.ts index fed0db3..bad25e9 100644 --- a/web-angular/src/app/views/privileges.component.ts +++ b/web-angular/src/app/views/privileges.component.ts @@ -65,6 +65,16 @@ export class PrivilegesComponent implements OnInit, OnDestroy, DoCheck { return this.tableHandler.getDisplayColumns(); } + getName(privilege: Privilege) { + console.dir(privilege); + if (privilege == null || privilege.shareInfo == null || privilege.shareInfo.name == null) { + return this.res.strings('privileges_nobody'); + } else { + return privilege.shareInfo.name; + } + + } + ngOnInit() { this.tableHandler = new TableHandler(this.table, PrivilegesComponent.COLUMNS); const token = this.activatedRoute.snapshot.paramMap.get('add');