From: David ‘Bombe’ Roden Date: Fri, 29 Nov 2019 06:04:51 +0000 (+0100) Subject: 🔀 Merge 'feature/remove-trust-functions' into 'next' X-Git-Tag: v81^2~17 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=95f0ee155c205ca5dddbb65f2c180a0a0308d4d3;hp=3335cbf7681220fcf95cff4895e025251211bf8e 🔀 Merge 'feature/remove-trust-functions' into 'next' --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index a8d753e..5c1e537 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -749,75 +749,6 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, } /** - * Sets the trust value of the given origin Sone for the target Sone. - * - * @param origin - * The origin Sone - * @param target - * The target Sone - * @param trustValue - * The trust value (from {@code -100} to {@code 100}) - */ - public void setTrust(Sone origin, Sone target, int trustValue) { - checkNotNull(origin, "origin must not be null"); - checkArgument(origin.getIdentity() instanceof OwnIdentity, "origin must be a local Sone"); - checkNotNull(target, "target must not be null"); - checkArgument((trustValue >= -100) && (trustValue <= 100), "trustValue must be within [-100, 100]"); - webOfTrustUpdater.setTrust((OwnIdentity) origin.getIdentity(), target.getIdentity(), trustValue, preferences.getTrustComment()); - } - - /** - * Removes any trust assignment for the given target Sone. - * - * @param origin - * The trust origin - * @param target - * The trust target - */ - public void removeTrust(Sone origin, Sone target) { - checkNotNull(origin, "origin must not be null"); - checkNotNull(target, "target must not be null"); - checkArgument(origin.getIdentity() instanceof OwnIdentity, "origin must be a local Sone"); - webOfTrustUpdater.setTrust((OwnIdentity) origin.getIdentity(), target.getIdentity(), null, null); - } - - /** - * Assigns the configured positive trust value for the given target. - * - * @param origin - * The trust origin - * @param target - * The trust target - */ - public void trustSone(Sone origin, Sone target) { - setTrust(origin, target, preferences.getPositiveTrust()); - } - - /** - * Assigns the configured negative trust value for the given target. - * - * @param origin - * The trust origin - * @param target - * The trust target - */ - public void distrustSone(Sone origin, Sone target) { - setTrust(origin, target, preferences.getNegativeTrust()); - } - - /** - * Removes the trust assignment for the given target. - * - * @param origin - * The trust origin - * @param target - * The trust target - */ - public void untrustSone(Sone origin, Sone target) { - removeTrust(origin, target); - } - - /** * Updates the stored Sone with the given Sone. * * @param sone diff --git a/src/main/java/net/pterodactylus/sone/core/PreferencesLoader.java b/src/main/java/net/pterodactylus/sone/core/PreferencesLoader.java index a730983..5fa33e4 100644 --- a/src/main/java/net/pterodactylus/sone/core/PreferencesLoader.java +++ b/src/main/java/net/pterodactylus/sone/core/PreferencesLoader.java @@ -23,9 +23,6 @@ public class PreferencesLoader { loadCharactersPerPost(configuration); loadPostCutOffLength(configuration); loadRequireFullAccess(configuration); - loadPositiveTrust(configuration); - loadNegativeTrust(configuration); - loadTrustComment(configuration); loadFcpInterfaceActive(configuration); loadFcpFullAccessRequired(configuration); } @@ -69,24 +66,6 @@ public class PreferencesLoader { .getValue(null)); } - private void loadPositiveTrust(Configuration configuration) { - preferences.setNewPositiveTrust( - configuration.getIntValue("Option/PositiveTrust") - .getValue(null)); - } - - private void loadNegativeTrust(Configuration configuration) { - preferences.setNewNegativeTrust( - configuration.getIntValue("Option/NegativeTrust") - .getValue(null)); - } - - private void loadTrustComment(Configuration configuration) { - preferences.setNewTrustComment( - configuration.getStringValue("Option/TrustComment") - .getValue(null)); - } - private void loadFcpInterfaceActive(Configuration configuration) { preferences.setNewFcpInterfaceActive(configuration.getBooleanValue( "Option/ActivateFcpInterface").getValue(null)); diff --git a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdater.java b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdater.java index 35c3203..95d066d 100644 --- a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdater.java +++ b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdater.java @@ -1,6 +1,5 @@ package net.pterodactylus.sone.core; -import net.pterodactylus.sone.freenet.wot.Identity; import net.pterodactylus.sone.freenet.wot.OwnIdentity; import net.pterodactylus.util.service.Service; @@ -12,7 +11,6 @@ import com.google.inject.ImplementedBy; @ImplementedBy(WebOfTrustUpdaterImpl.class) public interface WebOfTrustUpdater extends Service { - void setTrust(OwnIdentity truster, Identity trustee, Integer score, String comment); boolean addContextWait(OwnIdentity ownIdentity, String context); void removeContext(OwnIdentity ownIdentity, String context); void setProperty(OwnIdentity ownIdentity, String propertyName, String propertyValue); diff --git a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java index 809ca20..d0da223 100644 --- a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java +++ b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java @@ -26,11 +26,8 @@ import java.util.logging.Level; import java.util.logging.Logger; import net.pterodactylus.sone.freenet.plugin.PluginException; -import net.pterodactylus.sone.freenet.wot.Identity; import net.pterodactylus.sone.freenet.wot.OwnIdentity; -import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.sone.freenet.wot.WebOfTrustConnector; -import net.pterodactylus.sone.freenet.wot.WebOfTrustException; import net.pterodactylus.util.service.AbstractService; import com.google.common.annotations.VisibleForTesting; @@ -74,34 +71,6 @@ public class WebOfTrustUpdaterImpl extends AbstractService implements WebOfTrust // /** - * Updates the trust relation between the truster and the trustee. This method - * will return immediately and perform a trust update in the background. - * - * @param truster - * The identity giving the trust - * @param trustee - * The identity receiving the trust - * @param score - * The new level of trust (from -100 to 100, may be {@code null} to remove - * the trust completely) - * @param comment - * The comment of the trust relation - */ - @Override - public void setTrust(OwnIdentity truster, Identity trustee, Integer score, String comment) { - SetTrustJob setTrustJob = new SetTrustJob(truster, trustee, score, comment); - if (updateJobs.contains(setTrustJob)) { - updateJobs.remove(setTrustJob); - } - logger.log(Level.FINER, "Adding Trust Update Job: " + setTrustJob); - try { - updateJobs.put(setTrustJob); - } catch (InterruptedException e) { - /* the queue is unbounded so it should never block. */ - } - } - - /** * Adds the given context to the given own identity, waiting for completion of * the operation. * @@ -297,91 +266,6 @@ public class WebOfTrustUpdaterImpl extends AbstractService implements WebOfTrust } /** - * Update job that sets the trust relation between two identities. - */ - @VisibleForTesting - class SetTrustJob extends WebOfTrustUpdateJob { - - /** The identity giving the trust. */ - private final OwnIdentity truster; - - /** The identity receiving the trust. */ - private final Identity trustee; - - /** The score of the relation. */ - private final Integer score; - - /** The comment of the relation. */ - private final String comment; - - /** - * Creates a new set trust job. - * - * @param truster - * The identity giving the trust - * @param trustee - * The identity receiving the trust - * @param score - * The score of the trust (from -100 to 100, may be {@code null} to remote - * the trust relation completely) - * @param comment - * The comment of the trust relation - */ - public SetTrustJob(OwnIdentity truster, Identity trustee, Integer score, String comment) { - this.truster = checkNotNull(truster, "truster must not be null"); - this.trustee = checkNotNull(trustee, "trustee must not be null"); - this.score = score; - this.comment = comment; - } - - /** {@inheritDoc} */ - @Override - @SuppressWarnings("synthetic-access") - public void run() { - try { - if (score != null) { - webOfTrustConnector.setTrust(truster, trustee, score, comment); - trustee.setTrust(truster, new Trust(score, null, 0)); - } else { - webOfTrustConnector.removeTrust(truster, trustee); - trustee.removeTrust(truster); - } - finish(true); - } catch (WebOfTrustException wote1) { - logger.log(Level.WARNING, "Could not set Trust value for " + truster + " -> " + trustee + " to " + score + " (" + comment + ")!", wote1); - finish(false); - } - } - - // - // OBJECT METHODS - // - - /** {@inheritDoc} */ - @Override - public boolean equals(Object object) { - if ((object == null) || !object.getClass().equals(getClass())) { - return false; - } - SetTrustJob updateJob = (SetTrustJob) object; - return updateJob.truster.equals(truster) && updateJob.trustee.equals(trustee); - } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - return getClass().hashCode() ^ truster.hashCode() ^ trustee.hashCode(); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return String.format("%s[truster=%s,trustee=%s]", getClass().getSimpleName(), truster.getId(), trustee.getId()); - } - - } - - /** * Base class for context updates of an {@link OwnIdentity}. */ @VisibleForTesting diff --git a/src/main/java/net/pterodactylus/sone/web/AllPages.kt b/src/main/java/net/pterodactylus/sone/web/AllPages.kt index 9eccccf..c538f0e 100644 --- a/src/main/java/net/pterodactylus/sone/web/AllPages.kt +++ b/src/main/java/net/pterodactylus/sone/web/AllPages.kt @@ -23,7 +23,6 @@ class AllPages { @Inject lateinit var deleteReplyPage: DeleteReplyPage @Inject lateinit var deleteSonePage: DeleteSonePage @Inject lateinit var dismissNotificationPage: DismissNotificationPage - @Inject lateinit var distrustPage: DistrustPage @Inject lateinit var editAlbumPage: EditAlbumPage @Inject lateinit var editImagePage: EditImagePage @Inject lateinit var editProfileFieldPage: EditProfileFieldPage @@ -42,12 +41,10 @@ class AllPages { @Inject lateinit var optionsPage: OptionsPage @Inject lateinit var rescuePage: RescuePage @Inject lateinit var searchPage: SearchPage - @Inject lateinit var trustPage: TrustPage @Inject lateinit var unbookmarkPage: UnbookmarkPage @Inject lateinit var unfollowSonePage: UnfollowSonePage @Inject lateinit var unlikePage: UnlikePage @Inject lateinit var unlockSonePage: UnlockSonePage - @Inject lateinit var untrustPage: UntrustPage @Inject lateinit var uploadImagePage: UploadImagePage @Inject lateinit var viewPostPage: ViewPostPage @Inject lateinit var viewSonePage: ViewSonePage diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 588ffb7..e31d9a8 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -69,7 +69,6 @@ import net.pterodactylus.sone.web.ajax.DeletePostAjaxPage; import net.pterodactylus.sone.web.ajax.DeleteProfileFieldAjaxPage; import net.pterodactylus.sone.web.ajax.DeleteReplyAjaxPage; import net.pterodactylus.sone.web.ajax.DismissNotificationAjaxPage; -import net.pterodactylus.sone.web.ajax.DistrustAjaxPage; import net.pterodactylus.sone.web.ajax.EditAlbumAjaxPage; import net.pterodactylus.sone.web.ajax.EditImageAjaxPage; import net.pterodactylus.sone.web.ajax.EditProfileFieldAjaxPage; @@ -86,12 +85,10 @@ import net.pterodactylus.sone.web.ajax.LikeAjaxPage; import net.pterodactylus.sone.web.ajax.LockSoneAjaxPage; import net.pterodactylus.sone.web.ajax.MarkAsKnownAjaxPage; import net.pterodactylus.sone.web.ajax.MoveProfileFieldAjaxPage; -import net.pterodactylus.sone.web.ajax.TrustAjaxPage; import net.pterodactylus.sone.web.ajax.UnbookmarkAjaxPage; import net.pterodactylus.sone.web.ajax.UnfollowSoneAjaxPage; import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage; import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage; -import net.pterodactylus.sone.web.ajax.UntrustAjaxPage; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.sone.web.page.TemplateRenderer; import net.pterodactylus.sone.web.pages.*; @@ -574,9 +571,6 @@ public class WebInterface implements SessionProvider { pageToadletRegistry.addPage(new UploadImagePage(this, loaders, templateRenderer)); pageToadletRegistry.addPage(new EditImagePage(this, loaders, templateRenderer)); pageToadletRegistry.addPage(new DeleteImagePage(this, loaders, templateRenderer)); - pageToadletRegistry.addPage(new TrustPage(this, loaders, templateRenderer)); - pageToadletRegistry.addPage(new DistrustPage(this, loaders, templateRenderer)); - pageToadletRegistry.addPage(new UntrustPage(this, loaders, templateRenderer)); pageToadletRegistry.addPage(new MarkAsKnownPage(this, loaders, templateRenderer)); pageToadletRegistry.addPage(new BookmarkPage(this, loaders, templateRenderer)); pageToadletRegistry.addPage(new UnbookmarkPage(this, loaders, templateRenderer)); @@ -619,9 +613,6 @@ public class WebInterface implements SessionProvider { pageToadletRegistry.addPage(new UnfollowSoneAjaxPage(this)); pageToadletRegistry.addPage(new EditAlbumAjaxPage(this)); pageToadletRegistry.addPage(new EditImageAjaxPage(this, parserFilter, shortenFilter, renderFilter)); - pageToadletRegistry.addPage(new TrustAjaxPage(this)); - pageToadletRegistry.addPage(new DistrustAjaxPage(this)); - pageToadletRegistry.addPage(new UntrustAjaxPage(this)); pageToadletRegistry.addPage(new LikeAjaxPage(this)); pageToadletRegistry.addPage(new UnlikeAjaxPage(this)); pageToadletRegistry.addPage(new GetLikesAjaxPage(this)); diff --git a/src/main/kotlin/net/pterodactylus/sone/core/Preferences.kt b/src/main/kotlin/net/pterodactylus/sone/core/Preferences.kt index 783552e..7363ed0 100644 --- a/src/main/kotlin/net/pterodactylus/sone/core/Preferences.kt +++ b/src/main/kotlin/net/pterodactylus/sone/core/Preferences.kt @@ -77,24 +77,6 @@ class Preferences(private val eventBus: EventBus) { get() = unsupported set(value) = _requireFullAccess.set(value) - private val _positiveTrust = DefaultOption(75, range(0, 100)) - val positiveTrust: Int get() = _positiveTrust.get() - var newPositiveTrust: Int? - get() = unsupported - set(value) = _positiveTrust.set(value) - - private val _negativeTrust = DefaultOption(-25, range(-100, 100)) - val negativeTrust: Int get() = _negativeTrust.get() - var newNegativeTrust: Int? - get() = unsupported - set(value) = _negativeTrust.set(value) - - private val _trustComment = DefaultOption("Set from Sone Web Interface") - val trustComment: String get() = _trustComment.get() - var newTrustComment: String? - get() = unsupported - set(value) = _trustComment.set(value) - private val _fcpInterfaceActive = DefaultOption(false) val fcpInterfaceActive: Boolean get() = _fcpInterfaceActive.get() var newFcpInterfaceActive: Boolean? @@ -125,9 +107,6 @@ class Preferences(private val eventBus: EventBus) { configuration.getIntValue("Option/CharactersPerPost").value = _charactersPerPost.real configuration.getIntValue("Option/PostCutOffLength").value = _postCutOffLength.real configuration.getBooleanValue("Option/RequireFullAccess").value = _requireFullAccess.real - configuration.getIntValue("Option/PositiveTrust").value = _positiveTrust.real - configuration.getIntValue("Option/NegativeTrust").value = _negativeTrust.real - configuration.getStringValue("Option/TrustComment").value = _trustComment.real configuration.getBooleanValue("Option/ActivateFcpInterface").value = _fcpInterfaceActive.real configuration.getIntValue("Option/FcpFullAccessRequired").value = toInt(_fcpFullAccessRequired.real) } diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnector.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnector.kt index fae90ae..a8c40a6 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnector.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnector.kt @@ -64,19 +64,6 @@ class PluginWebOfTrustConnector @Inject constructor(private val pluginConnector: performRequest(SimpleFieldSetBuilder().put("Message", "RemoveProperty").put("Identity", ownIdentity.id).put("Property", name).get()) } - override fun getTrust(ownIdentity: OwnIdentity, identity: Identity) = - performRequest(SimpleFieldSetBuilder().put("Message", "GetIdentity").put("Truster", ownIdentity.id).put("Identity", identity.id).get()) - .fields - .parseTrust() - - override fun setTrust(ownIdentity: OwnIdentity, identity: Identity, trust: Int, comment: String) { - performRequest(SimpleFieldSetBuilder().put("Message", "SetTrust").put("Truster", ownIdentity.id).put("Trustee", identity.id).put("Value", trust.toString()).put("Comment", comment).get()) - } - - override fun removeTrust(ownIdentity: OwnIdentity, identity: Identity) { - performRequest(SimpleFieldSetBuilder().put("Message", "RemoveTrust").put("Truster", ownIdentity.id).put("Trustee", identity.id).get()) - } - override fun ping() { performRequest(SimpleFieldSetBuilder().put("Message", "Ping").get()) } diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.kt index 8488f16..e31dce6 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.kt @@ -70,41 +70,6 @@ interface WebOfTrustConnector { fun removeProperty(ownIdentity: OwnIdentity, name: String) /** - * Returns the trust for the given identity assigned to it by the given own - * identity. - * - * @param ownIdentity The own identity - * @param identity The identity to get the trust for - * @return The trust for the given identity - * @throws PluginException if an error occured talking to the Web of Trust plugin - */ - @Throws(PluginException::class) - fun getTrust(ownIdentity: OwnIdentity, identity: Identity): Trust - - /** - * Sets the trust for the given identity. - * - * @param ownIdentity The trusting identity - * @param identity The trusted identity - * @param trust The amount of trust (-100 thru 100) - * @param comment The comment or explanation of the trust value - * @throws PluginException if an error occured talking to the Web of Trust plugin - */ - @Throws(PluginException::class) - fun setTrust(ownIdentity: OwnIdentity, identity: Identity, trust: Int, comment: String) - - /** - * Removes any trust assignment of the given own identity for the given - * identity. - * - * @param ownIdentity The own identity - * @param identity The identity to remove all trust for - * @throws WebOfTrustException if an error occurs - */ - @Throws(WebOfTrustException::class) - fun removeTrust(ownIdentity: OwnIdentity, identity: Identity) - - /** * Pings the Web of Trust plugin. If the plugin can not be reached, a * [PluginException] is thrown. * diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt deleted file mode 100644 index cbeed6e..0000000 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt +++ /dev/null @@ -1,29 +0,0 @@ -package net.pterodactylus.sone.web.ajax - -import net.pterodactylus.sone.core.* -import net.pterodactylus.sone.data.* -import net.pterodactylus.sone.utils.* -import net.pterodactylus.sone.web.* -import net.pterodactylus.sone.web.page.* -import javax.inject.* - -/** - * AJAX page that lets the user distrust a Sone. - * - * @see Core.distrustSone(Sone, Sone) - */ -@ToadletPath("distrustSone.ajax") -class DistrustAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) { - - override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = - request.parameters["sone"] - ?.let(core::getSone) - ?.let { sone -> - createSuccessJsonObject() - .put("trustValue", core.preferences.negativeTrust) - .also { - core.distrustSone(currentSone, sone) - } - } ?: createErrorJsonObject("invalid-sone-id") - -} diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt deleted file mode 100644 index 9f0de87..0000000 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt +++ /dev/null @@ -1,24 +0,0 @@ -package net.pterodactylus.sone.web.ajax - -import net.pterodactylus.sone.data.* -import net.pterodactylus.sone.utils.* -import net.pterodactylus.sone.web.* -import net.pterodactylus.sone.web.page.* -import javax.inject.* - -/** - * AJAX page that lets the user trust a Sone. - * - * @see net.pterodactylus.sone.core.Core.trustSone - */ -@ToadletPath("trustSone.ajax") -class TrustAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) { - - override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = - request.parameters["sone"] - ?.let(core::getSone) - ?.let { core.trustSone(currentSone, it) } - ?.let { createSuccessJsonObject().put("trustValue", core.preferences.positiveTrust) } - ?: createErrorJsonObject("invalid-sone-id") - -} diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt deleted file mode 100644 index e4b5edb..0000000 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt +++ /dev/null @@ -1,22 +0,0 @@ -package net.pterodactylus.sone.web.ajax - -import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.utils.parameters -import net.pterodactylus.sone.web.WebInterface -import net.pterodactylus.sone.web.page.* -import javax.inject.Inject - -/** - * AJAX page that lets the user [untrust][net.pterodactylus.sone.core.Core.untrustSone] a [Sone]. - */ -@ToadletPath("untrustSone.ajax") -class UntrustAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) { - - override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = - request.parameters["sone"] - ?.let(core::getSone) - ?.also { core.untrustSone(currentSone, it) } - ?.let { createSuccessJsonObject() } - ?: createErrorJsonObject("invalid-sone-id") - -} diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt deleted file mode 100644 index dd3ad8c..0000000 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt +++ /dev/null @@ -1,29 +0,0 @@ -package net.pterodactylus.sone.web.pages - -import net.pterodactylus.sone.data.* -import net.pterodactylus.sone.main.* -import net.pterodactylus.sone.utils.* -import net.pterodactylus.sone.web.* -import net.pterodactylus.sone.web.page.* -import net.pterodactylus.util.template.* -import javax.inject.* - -/** - * Page that lets the user distrust another Sone. This will assign a - * configurable (negative) amount of trust to an identity. - * - * @see net.pterodactylus.sone.core.Core#distrustSone(Sone, Sone) - */ -@ToadletPath("distrust.html") -class DistrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : - LoggedInPage("Page.Distrust.Title", webInterface, loaders, templateRenderer) { - - override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { - if (soneRequest.isPOST) { - soneRequest.core.getSone(soneRequest.httpRequest.getPartAsStringFailsafe("sone", 44)) - ?.run { soneRequest.core.distrustSone(currentSone, this) } - redirectTo(soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)) - } - } - -} diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt index 2c454e8..412258d 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt @@ -50,9 +50,6 @@ class OptionsPage @Inject constructor(webInterface: WebInterface, loaders: Loade val imagesPerPage = soneRequest.parameters["images-per-page"]?.toIntOrNull() val insertionDelay = soneRequest.parameters["insertion-delay"]?.toIntOrNull() val fcpFullAccessRequired = soneRequest.parameters["fcp-full-access-required"]?.toIntOrNull() - val negativeTrust = soneRequest.parameters["negative-trust"]?.toIntOrNull() - val positiveTrust = soneRequest.parameters["positive-trust"]?.toIntOrNull() - val trustComment = soneRequest.parameters["trust-comment"]?.emptyToNull if (cantSetOption { soneRequest.core.preferences.newPostsPerPage = postsPerPage }) fieldsWithErrors += "posts-per-page" if (cantSetOption { soneRequest.core.preferences.newCharactersPerPost = charactersPerPost }) fieldsWithErrors += "characters-per-post" @@ -60,9 +57,6 @@ class OptionsPage @Inject constructor(webInterface: WebInterface, loaders: Loade if (cantSetOption { soneRequest.core.preferences.newImagesPerPage = imagesPerPage }) fieldsWithErrors += "images-per-page" if (cantSetOption { soneRequest.core.preferences.newInsertionDelay = insertionDelay }) fieldsWithErrors += "insertion-delay" fcpFullAccessRequired?.also { if (cantSetOption { soneRequest.core.preferences.newFcpFullAccessRequired = FullAccessRequired.values()[fcpFullAccessRequired] }) fieldsWithErrors += "fcp-full-access-required" } - if (cantSetOption { soneRequest.core.preferences.newNegativeTrust = negativeTrust }) fieldsWithErrors += "negative-trust" - if (cantSetOption { soneRequest.core.preferences.newPositiveTrust = positiveTrust }) fieldsWithErrors += "positive-trust" - if (cantSetOption { soneRequest.core.preferences.newTrustComment = trustComment }) fieldsWithErrors += "trust-comment" if (fieldsWithErrors.isEmpty()) { soneRequest.core.touchConfiguration() @@ -86,11 +80,8 @@ class OptionsPage @Inject constructor(webInterface: WebInterface, loaders: Loade templateContext["images-per-page"] = preferences.imagesPerPage templateContext["fcp-interface-active"] = preferences.fcpInterfaceActive templateContext["require-full-access"] = preferences.requireFullAccess - templateContext["negative-trust"] = preferences.negativeTrust - templateContext["positive-trust"] = preferences.positiveTrust templateContext["post-cut-off-length"] = preferences.postCutOffLength templateContext["posts-per-page"] = preferences.postsPerPage - templateContext["trust-comment"] = preferences.trustComment } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/TrustPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/TrustPage.kt deleted file mode 100644 index 54edc5d..0000000 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/TrustPage.kt +++ /dev/null @@ -1,28 +0,0 @@ -package net.pterodactylus.sone.web.pages - -import net.pterodactylus.sone.data.* -import net.pterodactylus.sone.main.* -import net.pterodactylus.sone.utils.* -import net.pterodactylus.sone.web.* -import net.pterodactylus.sone.web.page.* -import net.pterodactylus.util.template.* -import javax.inject.* - -/** - * Page that lets the user trust another Sone. This will assign a configurable - * amount of trust to an identity. - */ -@ToadletPath("trust.html") -class TrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : - LoggedInPage("Page.Trust.Title", webInterface, loaders, templateRenderer) { - - override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { - if (soneRequest.isPOST) { - soneRequest.core.getSone(soneRequest.parameters["sone"]!!)?.let { sone -> - soneRequest.core.trustSone(currentSone, sone) - } - redirectTo(soneRequest.parameters["returnPage", 256]) - } - } - -} diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt deleted file mode 100644 index dd445c8..0000000 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt +++ /dev/null @@ -1,28 +0,0 @@ -package net.pterodactylus.sone.web.pages - -import net.pterodactylus.sone.data.* -import net.pterodactylus.sone.main.* -import net.pterodactylus.sone.utils.* -import net.pterodactylus.sone.web.* -import net.pterodactylus.sone.web.page.* -import net.pterodactylus.util.template.* -import javax.inject.* - -/** - * Page that lets the user untrust another Sone. This will remove all trust - * assignments for an identity. - */ -@ToadletPath("untrust.html") -class UntrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : - LoggedInPage("Page.Untrust.Title", webInterface, loaders, templateRenderer) { - - override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { - if (soneRequest.isPOST) { - soneRequest.parameters["sone", 44]!! - .let(soneRequest.core::getSone) - ?.also { soneRequest.core.untrustSone(currentSone, it) } - redirectTo(soneRequest.parameters["returnPage", 256]) - } - } - -} diff --git a/src/main/resources/i18n/sone.de.properties b/src/main/resources/i18n/sone.de.properties index a3a95d6..a2ff8b1 100644 --- a/src/main/resources/i18n/sone.de.properties +++ b/src/main/resources/i18n/sone.de.properties @@ -66,10 +66,6 @@ Page.Options.Option.ImagesPerPage.Description=Anzahl der Bilder pro Seite. Page.Options.Option.CharactersPerPost.Description=Die Anzahl der Zeichen, die eine Nachricht enthalten muss, damit sie gekürzt angezeigt wird (-1 für „nie kürzen“). Die Anzahl der tatsächlich angezeigten Zeichen wird in der nächsten Option konfiguriert. Page.Options.Option.PostCutOffLength.Description=Die Anzahl der Zeichen, die von einer gekürzten Nachricht sichtbar sind (siehe Option hierüber). Wird ignoriert, wenn die Option hierüber deaktiviert ist, bzw. auf -1 steht. Page.Options.Option.RequireFullAccess.Description=Zugriff auf Sone für alle Rechner, die keinen vollen Zugriff haben, unterbinden. -Page.Options.Section.TrustOptions.Title=Vertrauenseinstellungen -Page.Options.Option.PositiveTrust.Description=Die Menge an positivem Vertrauen, die bei einem Klick auf den Haken unter einer Nachricht zugewiesen werden soll. -Page.Options.Option.NegativeTrust.Description=Die Menge an negativem Vertrauen, die bei einem Klick auf das rote X unter einer Nachricht zugewiesen werden soll. Dieser Wert sollte negativ sein. -Page.Options.Option.TrustComment.Description=Der Kommentar, der im Web of Trust für Ihre Zuweisung angezeigt werden soll. Page.Options.Section.FcpOptions.Title=FCP-Schnittstellenoptionen Page.Options.Option.FcpInterfaceActive.Description=Die FCP-Schnittstelle aktivieren, um anderen Plugins und Programmen den Zugriff auf Ihr Sone-Plugin zu ermöglichen. Page.Options.Option.FcpFullAccessRequired.Description=FCP-Verbindungen nur von „erlaubten Hosts“ erlauben (siehe {link}Knoten-Konfiguration, Abschnitt “FCP”{/link}). @@ -276,12 +272,6 @@ Page.DeleteAlbum.Text.AlbumWillBeGone=Ihr Album „{title}“ wird gelöscht. M Page.DeleteAlbum.Button.Yes=Ja, Album löschen. Page.DeleteAlbum.Button.No=Nein, Album nicht löschen. -Page.Trust.Title=Sone vertrauen - Sone - -Page.Distrust.Title=Sone misstrauen - Sone - -Page.Untrust.Title=Sone nicht vertrauen - Sone - Page.MarkAsKnown.Title=Als gelesen markieren - Sone Page.Bookmark.Title=Als Favorit markieren - Sone @@ -364,9 +354,10 @@ View.Sone.Status.Downloading=Diese Sone wird gerade herunter geladen. View.Sone.Status.Inserting=Diese Sone wird gerade hoch geladen. View.SoneMenu.Link.AllAlbums=alle Alben +View.SoneMenu.WebOfTrustLink=„Web of Trust“ Profil View.Post.UnknownAuthor=(unbekannt) -View.Post.WebOfTrustLink=„Web of Trust“ Profil +View.Post.WebOfTrustLink=WoT-Profil View.Post.Permalink=Nachrichtenlink View.Post.PermalinkAuthor=Autorenlink View.Post.Bookmarks.PostIsBookmarked=Nachricht ist ein Favorit, klicken, um Favoritenmarkierung zu entfernen @@ -383,10 +374,6 @@ View.Post.ShowLess=weniger zeigen View.UpdateStatus.Text.ChooseSenderIdentity=Absender wählen -View.Trust.Tooltip.Trust=Dieser Sone vertrauen -View.Trust.Tooltip.Distrust=Dieser Sone misstrauen -View.Trust.Tooltip.Untrust=Dieser Sone kein Vertrauen zuweisen - View.CreateAlbum.Title=Album anlegen View.CreateAlbum.Label.Name=Name: View.CreateAlbum.Label.Description=Beschreibung: @@ -437,9 +424,6 @@ WebInterface.DefaultText.Option.PostsPerPage=Anzahl der Nachrichten pro Seite WebInterface.DefaultText.Option.ImagesPerPage=Anzahl der Bilder pro Seite WebInterface.DefaultText.Option.CharactersPerPost=Anzahl der Zeichen, die eine Nachricht haben muss, damit er gekürzt wird WebInterface.DefaultText.Option.PostCutOffLength=Anzahl der Zeichen, die von einer gekürzten Nachricht angezeigt werden -WebInterface.DefaultText.Option.PositiveTrust=Der positive Vertrauenswert -WebInterface.DefaultText.Option.NegativeTrust=Der negative Vertrauenswert -WebInterface.DefaultText.Option.TrustComment=Der Kommentar für die Vertrauenszuweisung WebInterface.Button.Comment=Antworten WebInterface.Confirmation.DeletePostButton=Ja, löschen! WebInterface.Confirmation.DeleteReplyButton=Ja, löschen! diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index a23730c..c599f84 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -68,10 +68,6 @@ Page.Options.Option.ImagesPerPage.Description=The number of images to display on Page.Options.Option.CharactersPerPost.Description=The number of characters to display from a post before cutting it off and showing a link to expand it (-1 to disable). The actual length of the snippet is determined by the option below. Page.Options.Option.PostCutOffLength.Description=The number of characters that are displayed if a post is deemed too long (see option above). Ignored if “number of characters to display” is disabled (set to -1). Page.Options.Option.RequireFullAccess.Description=Whether to deny access to Sone to any host that has not been granted full access. -Page.Options.Section.TrustOptions.Title=Trust Settings -Page.Options.Option.PositiveTrust.Description=The amount of positive trust you want to assign to other Sones by clicking the checkmark below a post or reply. -Page.Options.Option.NegativeTrust.Description=The amount of trust you want to assign to other Sones by clicking the red X below a post or reply. This value should be negative. -Page.Options.Option.TrustComment.Description=The comment that will be set in the web of trust for any trust you assign from Sone. Page.Options.Section.FcpOptions.Title=FCP Interface Settings Page.Options.Option.FcpInterfaceActive.Description=Activate the FCP interface to allow other plugins and remote clients to access your Sone plugin. Page.Options.Option.FcpFullAccessRequired.Description=Require FCP connection from allowed hosts (see your {link}node’s configuration, section “FCP”{/link}) @@ -278,12 +274,6 @@ Page.DeleteAlbum.Text.AlbumWillBeGone=This will remove your album “{title}”. Page.DeleteAlbum.Button.Yes=Yes, delete album. Page.DeleteAlbum.Button.No=No, don’t delete album. -Page.Trust.Title=Trust Sone - Sone - -Page.Distrust.Title=Distrust Sone - Sone - -Page.Untrust.Title=Untrust Sone - Sone - Page.MarkAsKnown.Title=Mark as Known - Sone Page.Bookmark.Title=Bookmark - Sone @@ -366,9 +356,10 @@ View.Sone.Status.Downloading=This Sone is currently being downloaded. View.Sone.Status.Inserting=This Sone is currently being inserted. View.SoneMenu.Link.AllAlbums=all albums +View.SoneMenu.WebOfTrustLink=web of trust profile View.Post.UnknownAuthor=(unknown) -View.Post.WebOfTrustLink=web of trust profile +View.Post.WebOfTrustLink=WoT Profile View.Post.Permalink=link post View.Post.PermalinkAuthor=link author View.Post.Bookmarks.PostIsBookmarked=Post is bookmarked, click to remove from bookmarks @@ -385,10 +376,6 @@ View.Post.ShowLess=show less View.UpdateStatus.Text.ChooseSenderIdentity=Choose the sender identity -View.Trust.Tooltip.Trust=Trust this person -View.Trust.Tooltip.Distrust=Assign negative trust to this person -View.Trust.Tooltip.Untrust=Remove your trust assignment for this person - View.CreateAlbum.Title=Create Album View.CreateAlbum.Label.Name=Name: View.CreateAlbum.Label.Description=Description: @@ -439,9 +426,6 @@ WebInterface.DefaultText.Option.PostsPerPage=Number of posts to show on a page WebInterface.DefaultText.Option.ImagesPerPage=Number of images to show on a page WebInterface.DefaultText.Option.CharactersPerPost=Number of characters a post must have to be shortened WebInterface.DefaultText.Option.PostCutOffLength=Number of characters for the snippet of the shortened post -WebInterface.DefaultText.Option.PositiveTrust=The positive trust to assign -WebInterface.DefaultText.Option.NegativeTrust=The negative trust to assign -WebInterface.DefaultText.Option.TrustComment=The comment to set in the web of trust WebInterface.Button.Comment=Comment WebInterface.Confirmation.DeletePostButton=Yes, delete! WebInterface.Confirmation.DeleteReplyButton=Yes, delete! diff --git a/src/main/resources/i18n/sone.es.properties b/src/main/resources/i18n/sone.es.properties index 8a6e200..3a67a59 100644 --- a/src/main/resources/i18n/sone.es.properties +++ b/src/main/resources/i18n/sone.es.properties @@ -66,10 +66,6 @@ Page.Options.Option.ImagesPerPage.Description=Número de imágenes a mostrar en Page.Options.Option.CharactersPerPost.Description=Número de carácteres a mostrar de una publicación antes de acortarla y mostrar un link para expandirla (-1 para deshabilitar esta opción). La longitud de la acortación está determinada por la siguiente opción. Page.Options.Option.PostCutOffLength.Description=Número de carácteres que son mostrados si una publicación es demasiado larga (Mirar la opción anterior).Ignoralo si "Número de carácteres a mostrar" está desactivado (Valor en -1). Page.Options.Option.RequireFullAccess.Description=Denegar el acceso a Sone a cualquier host al que no se haya garantizado acceso completo. -Page.Options.Section.TrustOptions.Title=Opciones de veracidad. -Page.Options.Option.PositiveTrust.Description=Cantidad de veracidad positiva que quieres asignar a otros Sone al clicar en el tick tras una publicación o respuesta. -Page.Options.Option.NegativeTrust.Description=Cantidad de veracidad que quieres asignar a otros Sone al clicar la X roja tras una publicación o respuesta. Este valor debería ser negativo. -Page.Options.Option.TrustComment.Description=El comentario que se mostrara en la Web of Trust para cualquier veracidad que asignes desde Sone. Page.Options.Section.FcpOptions.Title=Opciones de la interfaz FCP Page.Options.Option.FcpInterfaceActive.Description=Activar la interfaz FCP para permitir a otros plugins y clientes remotos acceder al plugin de Sone. Page.Options.Option.FcpFullAccessRequired.Description=Requiere conexión FCP de los hosts permitidos (Comprueva tu {link}configuración del nodo, sección “FCP”{/link}) @@ -276,12 +272,6 @@ Page.DeleteAlbum.Text.AlbumWillBeGone=Esto eliminará tu álbum “{title}”. R Page.DeleteAlbum.Button.Yes=Si, eliminar álbum. Page.DeleteAlbum.Button.No=No, no eliminar álbum. -Page.Trust.Title=Dar veracidad al Sone - Sone - -Page.Distrust.Title=Retirar veracidad al Sone - Sone - -Page.Untrust.Title=Quitar veracidad al Sone - Sone - Page.MarkAsKnown.Title=Marcar como conocido - Sone Page.Bookmark.Title=Marcar - Sone @@ -364,6 +354,7 @@ View.Sone.Status.Downloading=Este Sone está siendo descargado. View.Sone.Status.Inserting=Este Sone está siendo insertado. View.SoneMenu.Link.AllAlbums=todos los albumes +View.SoneMenu.WebOfTrustLink=perfil de web of trust View.Post.UnknownAuthor=(desconocido) View.Post.WebOfTrustLink=perfil de web of trust @@ -383,10 +374,6 @@ View.Post.ShowLess=mostrar menos View.UpdateStatus.Text.ChooseSenderIdentity=Elegir la identidad del emisario -View.Trust.Tooltip.Trust=Creer a esta persona -View.Trust.Tooltip.Distrust=Asignar veracidad negativa a esta persona -View.Trust.Tooltip.Untrust=Eliminar la veracidad asignada a esta persona - View.CreateAlbum.Title=Crear Álbum View.CreateAlbum.Label.Name=Nombre: View.CreateAlbum.Label.Description=Descripción: @@ -437,9 +424,6 @@ WebInterface.DefaultText.Option.PostsPerPage=Número de publicaciones a mostrar WebInterface.DefaultText.Option.ImagesPerPage=Número de imágenes a mostrar en una página WebInterface.DefaultText.Option.CharactersPerPost=Número de carácteres de una publicación antes de acortarla WebInterface.DefaultText.Option.PostCutOffLength=Número de carácteres de los fragmentos de la publicación acortada -WebInterface.DefaultText.Option.PositiveTrust=Veracidad positiva a asignar -WebInterface.DefaultText.Option.NegativeTrust=Veracidad negativa a asignar -WebInterface.DefaultText.Option.TrustComment=Comentario a poner en Web of Trust WebInterface.Button.Comment=Comentar WebInterface.Confirmation.DeletePostButton=Si, eliminar! WebInterface.Confirmation.DeleteReplyButton=Si, eliminar! @@ -477,4 +461,4 @@ Notification.Mention.Text=Has sido mencionado en las siguientes publicaciones: Notification.SoneIsInserting.Text=Tu Sone sone://{0} está siendo insertado. Notification.SoneIsInserted.Text=Tu Sone sone://{0} ha sido insertado en {1,number} {1,choice,0#segundos|1#segundo|1<%sone.niceName|html> (<%= View.Sone.Stats.Posts|l10n 0=sone.posts.size>, <%= View.Sone.Stats.Replies|l10n 0=sone.replies.size><%if ! sone.allImages.size|match value==0>, <%= View.Sone.Stats.Images|l10n 0=sone.allImages.size><%/if><%if core.debug>, <% sone.client|html><%/if>) -
» <% =View.Post.WebOfTrustLink|l10n|html>
+
» <% =View.SoneMenu.WebOfTrustLink|l10n|html>
<%foreach sone.albums album> <%first>
» <% =View.SoneMenu.Link.AllAlbums|l10n|html>
diff --git a/src/main/resources/templates/include/viewPost.html b/src/main/resources/templates/include/viewPost.html index 7cdb924..be11195 100644 --- a/src/main/resources/templates/include/viewPost.html +++ b/src/main/resources/templates/include/viewPost.html @@ -93,30 +93,9 @@ - <%if !post.sone.current> - <%ifnull !post.sone.trust> - · -
- - - - -
-
- - - - -
-
- - - - -
- <%/if> - <%/if> <%/if> + · + <%= View.Post.WebOfTrustLink|l10n|html> <%if post.sone.local> ·
diff --git a/src/main/resources/templates/include/viewReply.html b/src/main/resources/templates/include/viewReply.html index 99c02e6..7462b2b 100644 --- a/src/main/resources/templates/include/viewReply.html +++ b/src/main/resources/templates/include/viewReply.html @@ -64,30 +64,9 @@
- <%if !reply.sone.current> - <%ifnull !reply.sone.trust> - · -
- - - - -
-
- - - - -
-
- - - - -
- <%/if> - <%/if> <%/if> + · + <%= View.Post.WebOfTrustLink|l10n|html> <%if reply.sone.local> ·
diff --git a/src/main/resources/templates/options.html b/src/main/resources/templates/options.html index c7760ef..c4baf2a 100644 --- a/src/main/resources/templates/options.html +++ b/src/main/resources/templates/options.html @@ -17,15 +17,6 @@ getTranslation("WebInterface.DefaultText.Option.PostCutOffLength", function(postCutOffLengthText) { registerInputTextareaSwap("#sone #options input[name=post-cut-off-length]", postCutOffLengthText, "post-cut-off-length", true, true); }); - getTranslation("WebInterface.DefaultText.Option.PositiveTrust", function(positiveTrustText) { - registerInputTextareaSwap("#sone #options input[name=positive-trust]", positiveTrustText, "positive-trust", true, true); - }); - getTranslation("WebInterface.DefaultText.Option.NegativeTrust", function(negativeTrustText) { - registerInputTextareaSwap("#sone #options input[name=negative-trust]", negativeTrustText, "negative-trust", true, true); - }); - getTranslation("WebInterface.DefaultText.Option.TrustComment", function(trustCommentText) { - registerInputTextareaSwap("#sone #options input[name=trust-comment]", trustCommentText, "trust-comment", true, true); - }); }); @@ -160,23 +151,6 @@ <%= Page.Options.Option.RequireFullAccess.Description|l10n|html>

-

<%= Page.Options.Section.TrustOptions.Title|l10n|html>

- -

<%= Page.Options.Option.PositiveTrust.Description|l10n|html>

- <%if =positive-trust|in collection=fieldErrors> -

<%= Page.Options.Warnings.ValueNotChanged|l10n|html>

- <%/if> -

- -

<%= Page.Options.Option.NegativeTrust.Description|l10n|html>

- <%if =negative-trust|in collection=fieldErrors> -

<%= Page.Options.Warnings.ValueNotChanged|l10n|html>

- <%/if> -

- -

<%= Page.Options.Option.TrustComment.Description|l10n|html>

-

-

<%= Page.Options.Section.FcpOptions.Title|l10n|html>

checked="checked"<%/if> /> <%= Page.Options.Option.FcpInterfaceActive.Description|l10n|html>

diff --git a/src/test/java/net/pterodactylus/sone/core/PreferencesLoaderTest.java b/src/test/java/net/pterodactylus/sone/core/PreferencesLoaderTest.java index d550f25..72831fc 100644 --- a/src/test/java/net/pterodactylus/sone/core/PreferencesLoaderTest.java +++ b/src/test/java/net/pterodactylus/sone/core/PreferencesLoaderTest.java @@ -33,10 +33,6 @@ public class PreferencesLoaderTest { setupIntValue("CharactersPerPost", 150); setupIntValue("PostCutOffLength", 300); setupBooleanValue("RequireFullAccess", true); - setupIntValue("PositiveTrust", 50); - setupIntValue("NegativeTrust", -50); - when(configuration.getStringValue("Option/TrustComment")).thenReturn( - TestValue.from("Trusted")); setupBooleanValue("ActivateFcpInterface", true); setupIntValue("FcpFullAccessRequired", 1); } @@ -62,9 +58,6 @@ public class PreferencesLoaderTest { assertThat(preferences.getCharactersPerPost(), is(150)); assertThat(preferences.getPostCutOffLength(), is(300)); assertThat(preferences.getRequireFullAccess(), is(true)); - assertThat(preferences.getPositiveTrust(), is(50)); - assertThat(preferences.getNegativeTrust(), is(-50)); - assertThat(preferences.getTrustComment(), is("Trusted")); assertThat(preferences.getFcpInterfaceActive(), is(true)); assertThat(preferences.getFcpFullAccessRequired(), is(WRITING)); } diff --git a/src/test/java/net/pterodactylus/sone/core/WebOfTrustUpdaterTest.java b/src/test/java/net/pterodactylus/sone/core/WebOfTrustUpdaterTest.java index 0c923fc..d7d9b48 100644 --- a/src/test/java/net/pterodactylus/sone/core/WebOfTrustUpdaterTest.java +++ b/src/test/java/net/pterodactylus/sone/core/WebOfTrustUpdaterTest.java @@ -14,15 +14,12 @@ import java.util.concurrent.CountDownLatch; import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.AddContextJob; import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.RemoveContextJob; import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.SetPropertyJob; -import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.SetTrustJob; import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.WebOfTrustContextUpdateJob; import net.pterodactylus.sone.core.WebOfTrustUpdaterImpl.WebOfTrustUpdateJob; import net.pterodactylus.sone.freenet.plugin.PluginException; import net.pterodactylus.sone.freenet.wot.Identity; import net.pterodactylus.sone.freenet.wot.OwnIdentity; -import net.pterodactylus.sone.freenet.wot.Trust; import net.pterodactylus.sone.freenet.wot.WebOfTrustConnector; -import net.pterodactylus.sone.freenet.wot.WebOfTrustException; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; @@ -34,9 +31,6 @@ import org.mockito.stubbing.Answer; public class WebOfTrustUpdaterTest { private static final String CONTEXT = "test-context"; - private static final Integer SCORE = 50; - private static final Integer OTHER_SCORE = 25; - private static final String TRUST_COMMENT = "set in a test"; private static final String PROPERTY_NAME = "test-property"; private final WebOfTrustConnector webOfTrustConnector = mock(WebOfTrustConnector.class); private final WebOfTrustUpdaterImpl webOfTrustUpdater = new WebOfTrustUpdaterImpl(webOfTrustConnector); @@ -46,7 +40,6 @@ public class WebOfTrustUpdaterTest { private final WebOfTrustContextUpdateJob contextUpdateJob = webOfTrustUpdater.new WebOfTrustContextUpdateJob(ownIdentity, CONTEXT); private final AddContextJob addContextJob = webOfTrustUpdater.new AddContextJob(ownIdentity, CONTEXT); private final RemoveContextJob removeContextJob = webOfTrustUpdater.new RemoveContextJob(ownIdentity, CONTEXT); - private final Identity trustee = when(mock(Identity.class).getId()).thenReturn("trustee-id").getMock(); private WebOfTrustUpdateJob createWebOfTrustUpdateJob(final boolean success) { return webOfTrustUpdater.new WebOfTrustUpdateJob() { @@ -230,81 +223,6 @@ public class WebOfTrustUpdaterTest { } @Test - public void setTrustJobSetsTrust() throws PluginException { - SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT); - setTrustJob.run(); - verify(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT)); - verify(trustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0))); - assertThat(setTrustJob.waitForCompletion(), is(true)); - } - - @Test - public void settingNullTrustRemovesTrust() throws WebOfTrustException { - SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, null, TRUST_COMMENT); - setTrustJob.run(); - verify(webOfTrustConnector).removeTrust(eq(ownIdentity), eq(trustee)); - verify(trustee).removeTrust(eq(ownIdentity)); - assertThat(setTrustJob.waitForCompletion(), is(true)); - } - - @Test - public void exceptionWhileSettingTrustIsCaught() throws PluginException { - doThrow(PluginException.class).when(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT)); - SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT); - setTrustJob.run(); - verify(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT)); - verify(trustee, never()).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0))); - assertThat(setTrustJob.waitForCompletion(), is(false)); - } - - @Test - public void setTrustJobsWithDifferentClassesAreNotEqual() { - SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT); - SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT) { - }; - assertThat(firstSetTrustJob, not(is(secondSetTrustJob))); - assertThat(secondSetTrustJob, not(is(firstSetTrustJob))); - } - - @Test - public void setTrustJobsWithDifferentTrustersAreNotEqual() { - SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT); - SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(mock(OwnIdentity.class), trustee, SCORE, TRUST_COMMENT); - assertThat(firstSetTrustJob, not(is(secondSetTrustJob))); - assertThat(secondSetTrustJob, not(is(firstSetTrustJob))); - } - - @Test - public void setTrustJobsWithDifferentTrusteesAreNotEqual() { - SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT); - SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, mock(Identity.class), SCORE, TRUST_COMMENT); - assertThat(firstSetTrustJob, not(is(secondSetTrustJob))); - assertThat(secondSetTrustJob, not(is(firstSetTrustJob))); - } - - @Test - public void setTrustJobsWithDifferentScoreAreEqual() { - SetTrustJob firstSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT); - SetTrustJob secondSetTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, OTHER_SCORE, TRUST_COMMENT); - assertThat(firstSetTrustJob, is(secondSetTrustJob)); - assertThat(secondSetTrustJob, is(firstSetTrustJob)); - assertThat(firstSetTrustJob.hashCode(), is(secondSetTrustJob.hashCode())); - } - - @Test - public void setTrustJobDoesNotEqualNull() { - SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT); - assertThat(setTrustJob, not(is((Object) null))); - } - - @Test - public void toStringOfSetTrustJobContainsIdsOfTrusterAndTrustee() { - SetTrustJob setTrustJob = webOfTrustUpdater.new SetTrustJob(ownIdentity, trustee, SCORE, TRUST_COMMENT); - assertThat(setTrustJob.toString(), containsString(ownIdentity.getId())); - assertThat(setTrustJob.toString(), containsString(trustee.getId())); - } - - @Test public void webOfTrustUpdaterStopsWhenItShould() { webOfTrustUpdater.stop(); webOfTrustUpdater.serviceRun(); @@ -399,44 +317,4 @@ public class WebOfTrustUpdaterTest { verify(ownIdentity).removeContext(eq(CONTEXT)); } - @Test - public void setTrustSetsTrust() throws InterruptedException, PluginException { - final CountDownLatch trustSetTrigger = new CountDownLatch(1); - doAnswer(new Answer() { - @Override - public Void answer(InvocationOnMock invocation) throws Throwable { - trustSetTrigger.countDown(); - return null; - } - }).when(trustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0))); - webOfTrustUpdater.start(); - webOfTrustUpdater.setTrust(ownIdentity, trustee, SCORE, TRUST_COMMENT); - assertThat(trustSetTrigger.await(1, SECONDS), is(true)); - verify(trustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0))); - verify(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT)); - } - - @Test - public void setTrustRequestsAreCoalesced() throws InterruptedException, PluginException { - final CountDownLatch firstTrigger = new CountDownLatch(1); - doAnswer((Answer) invocation -> { - firstTrigger.countDown(); - return null; - }).when(trustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0))); - Identity secondTrustee = when(mock(Identity.class).getId()).thenReturn("trustee-id2").getMock(); - final CountDownLatch secondTrigger = new CountDownLatch(1); - doAnswer((Answer) invocation -> { - secondTrigger.countDown(); - return null; - }).when(secondTrustee).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0))); - webOfTrustUpdater.setTrust(ownIdentity, trustee, SCORE, TRUST_COMMENT); - webOfTrustUpdater.setTrust(ownIdentity, secondTrustee, SCORE, TRUST_COMMENT); - webOfTrustUpdater.setTrust(ownIdentity, trustee, SCORE, TRUST_COMMENT); - webOfTrustUpdater.start(); - assertThat(firstTrigger.await(1, SECONDS), is(true)); - assertThat(secondTrigger.await(1, SECONDS), is(true)); - verify(trustee, times(1)).setTrust(eq(ownIdentity), eq(new Trust(SCORE, null, 0))); - verify(webOfTrustConnector).setTrust(eq(ownIdentity), eq(trustee), eq(SCORE), eq(TRUST_COMMENT)); - } - } diff --git a/src/test/kotlin/net/pterodactylus/sone/core/PreferencesTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/PreferencesTest.kt index 199604b..6da6658 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/PreferencesTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/PreferencesTest.kt @@ -180,69 +180,6 @@ class PreferencesTest { } @Test - fun `preferences retain positive trust`() { - preferences.newPositiveTrust = 15 - assertThat(preferences.positiveTrust, equalTo(15)) - } - - @Test(expected = IllegalArgumentException::class) - fun `invalid positive trust is rejected`() { - preferences.newPositiveTrust = -15 - } - - @Test - fun `preferences return default value when positive trust is set to null`() { - preferences.newPositiveTrust = null - assertThat(preferences.positiveTrust, equalTo(75)) - } - - @Test - fun `preferences start with positive trust default value`() { - assertThat(preferences.positiveTrust, equalTo(75)) - } - - @Test - fun `preferences retain negative trust`() { - preferences.newNegativeTrust = -15 - assertThat(preferences.negativeTrust, equalTo(-15)) - } - - @Test(expected = IllegalArgumentException::class) - fun `invalid negative trust is rejected`() { - preferences.newNegativeTrust = 150 - } - - @Test - fun `preferences return default value when negative trust is set to null`() { - preferences.newNegativeTrust = null - assertThat(preferences.negativeTrust, equalTo(-25)) - } - - @Test - fun `preferences start with negative trust default value`() { - assertThat(preferences.negativeTrust, equalTo(-25)) - } - - @Test - fun `preferences retain trust comment`() { - preferences.newTrustComment = "Trust" - assertThat(preferences.trustComment, equalTo("Trust")) - } - - @Test - fun `preferences return default value when trust comment is set to null`() { - preferences.newTrustComment = null - assertThat(preferences.trustComment, - equalTo("Set from Sone Web Interface")) - } - - @Test - fun `preferences start with trust comment default value`() { - assertThat(preferences.trustComment, - equalTo("Set from Sone Web Interface")) - } - - @Test fun `preferences retain fcp interface active of true`() { preferences.newFcpInterfaceActive = true assertThat(preferences.fcpInterfaceActive, equalTo(true)) diff --git a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.kt b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.kt index 780288d..1202d4c 100644 --- a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.kt @@ -110,9 +110,6 @@ private open class TestWebOfTrustConnector : WebOfTrustConnector { override fun removeContext(ownIdentity: OwnIdentity, context: String) = Unit override fun setProperty(ownIdentity: OwnIdentity, name: String, value: String) = Unit override fun removeProperty(ownIdentity: OwnIdentity, name: String) = Unit - override fun getTrust(ownIdentity: OwnIdentity, identity: Identity) = Trust(null, null, null) - override fun setTrust(ownIdentity: OwnIdentity, identity: Identity, trust: Int, comment: String) = Unit - override fun removeTrust(ownIdentity: OwnIdentity, identity: Identity) = Unit override fun ping() = Unit } diff --git a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt index 1af177f..a9c0412 100644 --- a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt @@ -17,7 +17,6 @@ import kotlin.test.* class PluginWebOfTrustConnectorTest { private val ownIdentity = DefaultOwnIdentity("id", "nickname", "requestUri", "insertUri") - private val identity = DefaultIdentity("id-a", "alpha", "url://alpha") @Test fun `wot plugin can be pinged`() { @@ -224,94 +223,6 @@ class PluginWebOfTrustConnectorTest { .connect { removeProperty(ownIdentity, "TestProperty") } } - @Test - fun `getting trust sends correct own identity id`() { - createPluginConnector("GetIdentity", hasField("Truster", equalTo(ownIdentity.id))) - .connect { getTrust(ownIdentity, identity) } - } - - @Test - fun `getting trust sends correct identity id`() { - createPluginConnector("GetIdentity", hasField("Identity", equalTo(identity.id))) - .connect { getTrust(ownIdentity, identity) } - } - - @Test - fun `getting trust returns correct trust values`() { - val trust = createPluginConnector("GetIdentity", hasField("Identity", equalTo(identity.id))) { - put("Trust", "12") - put("Score", "34") - put("Rank", "56") - }.connect { getTrust(ownIdentity, identity) } - assertThat(trust, isTrust(12, 34, 56)) - } - - @Test - fun `getting trust reads incorrect numbers for trust as null`() { - val trust = createPluginConnector("GetIdentity", hasField("Identity", equalTo(identity.id))) { - put("Trust", "incorrect") - put("Score", "34") - put("Rank", "56") - }.connect { getTrust(ownIdentity, identity) } - assertThat(trust, isTrust(null, 34, 56)) - } - - @Test - fun `getting trust reads incorrect numbers for score as null`() { - val trust = createPluginConnector("GetIdentity", hasField("Identity", equalTo(identity.id))) { - put("Trust", "12") - put("Score", "incorrect") - put("Rank", "56") - }.connect { getTrust(ownIdentity, identity) } - assertThat(trust, isTrust(12, null, 56)) - } - - @Test - fun `getting trust reads incorrect numbers for rank as null`() { - val trust = createPluginConnector("GetIdentity", hasField("Identity", equalTo(identity.id))) { - put("Trust", "12") - put("Score", "34") - put("Rank", "incorrect") - }.connect { getTrust(ownIdentity, identity) } - assertThat(trust, isTrust(12, 34, null)) - } - - @Test - fun `setting trust sends correct own identity id`() { - createPluginConnector("SetTrust", hasField("Truster", equalTo(ownIdentity.id))) - .connect { setTrust(ownIdentity, identity, 123, "Test Trust") } - } - - @Test - fun `setting trust sends correct identity id`() { - createPluginConnector("SetTrust", hasField("Trustee", equalTo(identity.id))) - .connect { setTrust(ownIdentity, identity, 123, "Test Trust") } - } - - @Test - fun `setting trust sends correct trust value`() { - createPluginConnector("SetTrust", hasField("Value", equalTo("123"))) - .connect { setTrust(ownIdentity, identity, 123, "Test Trust") } - } - - @Test - fun `setting trust sends correct comment`() { - createPluginConnector("SetTrust", hasField("Comment", equalTo("Test Trust"))) - .connect { setTrust(ownIdentity, identity, 123, "Test Trust") } - } - - @Test - fun `removing trust sends correct own identity id`() { - createPluginConnector("RemoveTrust", hasField("Truster", equalTo(ownIdentity.id))) - .connect { removeTrust(ownIdentity, identity) } - } - - @Test - fun `removing trust sends correct identity id`() { - createPluginConnector("RemoveTrust", hasField("Trustee", equalTo(identity.id))) - .connect { removeTrust(ownIdentity, identity) } - } - } private fun PluginConnector.connect(block: PluginWebOfTrustConnector.() -> R) = diff --git a/src/test/kotlin/net/pterodactylus/sone/web/AllPagesTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/AllPagesTest.kt index cf6ab15..842feb4 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/AllPagesTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/AllPagesTest.kt @@ -102,11 +102,6 @@ class AllPagesTest { } @Test - fun `distrust page can be injected`() { - assertThat(allPages.distrustPage, instanceOf()) - } - - @Test fun `edit album page can be injected`() { assertThat(allPages.editAlbumPage, instanceOf()) } @@ -197,11 +192,6 @@ class AllPagesTest { } @Test - fun `trust page can be injected`() { - assertThat(allPages.trustPage, instanceOf()) - } - - @Test fun `unbookmark page can be injected`() { assertThat(allPages.unbookmarkPage, instanceOf()) } @@ -222,11 +212,6 @@ class AllPagesTest { } @Test - fun `untrust page can be injected`() { - assertThat(allPages.untrustPage, instanceOf()) - } - - @Test fun `upload image page can be injected`() { assertThat(allPages.uploadImagePage, instanceOf()) } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPageTest.kt deleted file mode 100644 index 868819e..0000000 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPageTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -package net.pterodactylus.sone.web.ajax - -import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.test.getInstance -import net.pterodactylus.sone.test.mock -import net.pterodactylus.sone.web.baseInjector -import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.equalTo -import org.hamcrest.Matchers.notNullValue -import org.junit.Test -import org.mockito.Mockito.verify - -/** - * Unit test for [DistrustAjaxPage]. - */ -class DistrustAjaxPageTest : JsonPageTest("distrustSone.ajax", pageSupplier = ::DistrustAjaxPage) { - - @Test - fun `request with missing sone results in invalid-sone-id`() { - assertThatJsonFailed("invalid-sone-id") - } - - @Test - fun `request with invalid sone results in invalid-sone-id`() { - addRequestParameter("sone", "invalid-sone") - assertThatJsonFailed("invalid-sone-id") - } - - @Test - fun `request with valid sone results in distrusted sone`() { - val sone = mock() - addSone(sone, "sone-id") - addRequestParameter("sone", "sone-id") - assertThatJsonIsSuccessful() - verify(core).distrustSone(currentSone, sone) - } - - @Test - fun `request with valid sone results in correct trust value being sent back`() { - core.preferences.newNegativeTrust = -33 - val sone = mock() - addSone(sone, "sone-id") - addRequestParameter("sone", "sone-id") - assertThatJsonIsSuccessful() - assertThat(json["trustValue"]?.asInt(), equalTo(-33)) - } - - @Test - fun `page can be created by dependency injection`() { - assertThat(baseInjector.getInstance(), notNullValue()) - } - -} diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPageTest.kt deleted file mode 100644 index d557790..0000000 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPageTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -package net.pterodactylus.sone.web.ajax - -import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.test.getInstance -import net.pterodactylus.sone.test.mock -import net.pterodactylus.sone.web.baseInjector -import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.equalTo -import org.hamcrest.Matchers.notNullValue -import org.junit.Test -import org.mockito.Mockito.verify - -/** - * Unit test for [TrustAjaxPage]. - */ -class TrustAjaxPageTest : JsonPageTest("trustSone.ajax", requiresLogin = true, needsFormPassword = true, pageSupplier = ::TrustAjaxPage) { - - private val sone = mock() - - @Test - fun `request with invalid sone results in invalid-sone-id`() { - assertThatJsonFailed("invalid-sone-id") - } - - @Test - fun `request with valid sone trust sone`() { - addSone(sone, "sone-id") - addRequestParameter("sone", "sone-id") - assertThatJsonIsSuccessful() - verify(core).trustSone(currentSone, sone) - } - - @Test - fun `request with valid sone returns positive trust value`() { - addSone(sone, "sone-id") - addRequestParameter("sone", "sone-id") - core.preferences.newPositiveTrust = 31 - assertThatJsonIsSuccessful() - assertThat(json["trustValue"]?.asInt(), equalTo(31)) - } - - @Test - fun `page can be created by dependency injection`() { - assertThat(baseInjector.getInstance(), notNullValue()) - } - -} diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPageTest.kt deleted file mode 100644 index b693194..0000000 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPageTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -package net.pterodactylus.sone.web.ajax - -import net.pterodactylus.sone.data.* -import net.pterodactylus.sone.test.* -import net.pterodactylus.sone.web.* -import org.hamcrest.MatcherAssert.* -import org.hamcrest.Matchers.* -import org.junit.* -import org.mockito.Mockito.* - -/** - * Unit test for [UntrustAjaxPage]. - */ -class UntrustAjaxPageTest : JsonPageTest("untrustSone.ajax", pageSupplier = ::UntrustAjaxPage) { - - @Test - fun `request without sone results in invalid-sone-id`() { - assertThatJsonFailed("invalid-sone-id") - } - - @Test - fun `request with invalid sone results in invalid-sone-id`() { - addRequestParameter("sone", "invalid") - assertThatJsonFailed("invalid-sone-id") - } - - @Test - fun `request with valid sone results in sone being untrusted`() { - val sone = mock() - addSone(sone, "sone-id") - addRequestParameter("sone", "sone-id") - assertThatJsonIsSuccessful() - verify(core).untrustSone(currentSone, sone) - } - - @Test - fun `request with valid sone results in null trust value being returned`() { - val sone = mock() - addSone(sone, "sone-id") - addRequestParameter("sone", "sone-id") - assertThatJsonIsSuccessful() - assertThat(json["trustValue"], nullValue()) - } - - @Test - fun `page can be created by dependency injection`() { - assertThat(baseInjector.getInstance(), notNullValue()) - } - -} diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt deleted file mode 100644 index df16a53..0000000 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -package net.pterodactylus.sone.web.pages - -import net.pterodactylus.sone.data.* -import net.pterodactylus.sone.test.* -import net.pterodactylus.sone.web.* -import net.pterodactylus.util.web.Method.* -import org.hamcrest.MatcherAssert.* -import org.hamcrest.Matchers.* -import org.junit.* -import org.mockito.Mockito.* - -/** - * Unit test for [DistrustPage]. - */ -class DistrustPageTest : WebPageTest(::DistrustPage) { - - @Test - fun `page returns correct path`() { - assertThat(page.path, equalTo("distrust.html")) - } - - @Test - fun `page requires login`() { - assertThat(page.requiresLogin(), equalTo(true)) - } - - @Test - fun `page returns correct title`() { - addTranslation("Page.Distrust.Title", "distrust page title") - assertThat(page.getPageTitle(soneRequest), equalTo("distrust page title")) - } - - @Test - fun `get request does not redirect`() { - page.processTemplate(freenetRequest, templateContext) - } - - @Test - fun `post request with invalid sone redirects to return page`() { - setMethod(POST) - addHttpRequestPart("returnPage", "return.html") - verifyRedirect("return.html") - } - - @Test - fun `post request with valid sone distrusts sone and redirects to return page`() { - setMethod(POST) - val remoteSone = mock() - addSone("remote-sone-id", remoteSone) - addHttpRequestPart("returnPage", "return.html") - addHttpRequestPart("sone", "remote-sone-id") - verifyRedirect("return.html") { - verify(core).distrustSone(currentSone, remoteSone) - } - } - - @Test - fun `page can be created by dependency injection`() { - assertThat(baseInjector.getInstance(), notNullValue()) - } - -} diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt index 71e1b7b..d2929d9 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt @@ -25,11 +25,8 @@ class OptionsPageTest : WebPageTest(::OptionsPage) { core.preferences.newImagesPerPage = 4 core.preferences.newFcpInterfaceActive = true core.preferences.newRequireFullAccess = true - core.preferences.newNegativeTrust = 7 - core.preferences.newPositiveTrust = 8 core.preferences.newPostCutOffLength = 51 core.preferences.newPostsPerPage = 10 - core.preferences.newTrustComment = "11" } @Before @@ -77,11 +74,8 @@ class OptionsPageTest : WebPageTest(::OptionsPage) { assertThat(templateContext["images-per-page"], equalTo(4)) assertThat(templateContext["fcp-interface-active"], equalTo(true)) assertThat(templateContext["require-full-access"], equalTo(true)) - assertThat(templateContext["negative-trust"], equalTo(7)) - assertThat(templateContext["positive-trust"], equalTo(8)) assertThat(templateContext["post-cut-off-length"], equalTo(51)) assertThat(templateContext["posts-per-page"], equalTo(10)) - assertThat(templateContext["trust-comment"], equalTo("11")) } } @@ -284,56 +278,6 @@ class OptionsPageTest : WebPageTest(::OptionsPage) { } @Test - fun `negative trust can not be set to -101`() { - verifyThatWrongValueForPreferenceIsDetected("negative-trust", "-101") - } - - @Test - fun `negative trust can be set to -100`() { - verifyThatPreferencesCanBeSet("negative-trust", "-100", -100) { core.preferences.negativeTrust } - } - - @Test - fun `negative trust can be set to 100`() { - verifyThatPreferencesCanBeSet("negative-trust", "100", 100) { core.preferences.negativeTrust } - } - - @Test - fun `negative trust can not be set to 101`() { - verifyThatWrongValueForPreferenceIsDetected("negative-trust", "101") - } - - @Test - fun `negative trust is set to default on invalid value`() { - verifyThatPreferencesCanBeSet("negative-trust", "invalid", -25) { core.preferences.negativeTrust } - } - - @Test - fun `positive trust can not be set to -1`() { - verifyThatWrongValueForPreferenceIsDetected("positive-trust", "-1") - } - - @Test - fun `positive trust can be set to 0`() { - verifyThatPreferencesCanBeSet("positive-trust", "0", 0) { core.preferences.positiveTrust } - } - - @Test - fun `positive trust can be set to 100`() { - verifyThatPreferencesCanBeSet("positive-trust", "100", 100) { core.preferences.positiveTrust } - } - - @Test - fun `positive trust can not be set to 101`() { - verifyThatWrongValueForPreferenceIsDetected("positive-trust", "101") - } - - @Test - fun `positive trust is set to default on invalid value`() { - verifyThatPreferencesCanBeSet("positive-trust", "invalid", 75) { core.preferences.positiveTrust } - } - - @Test fun `post cut off length can not be set to -49`() { verifyThatWrongValueForPreferenceIsDetected("post-cut-off-length", "-49") } @@ -364,16 +308,6 @@ class OptionsPageTest : WebPageTest(::OptionsPage) { } @Test - fun `trust comment can be set`() { - verifyThatPreferencesCanBeSet("trust-comment", "trust", "trust") { core.preferences.trustComment } - } - - @Test - fun `trust comment is set to default when set to empty value`() { - verifyThatPreferencesCanBeSet("trust-comment", "", "Set from Sone Web Interface") { core.preferences.trustComment } - } - - @Test fun `page can be created by dependency injection`() { assertThat(baseInjector.getInstance(), notNullValue()) } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt deleted file mode 100644 index 990c1b7..0000000 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -package net.pterodactylus.sone.web.pages - -import net.pterodactylus.sone.data.* -import net.pterodactylus.sone.test.getInstance -import net.pterodactylus.sone.test.mock -import net.pterodactylus.sone.web.* -import net.pterodactylus.util.web.Method.* -import org.hamcrest.MatcherAssert.* -import org.hamcrest.Matchers.* -import org.junit.* -import org.mockito.ArgumentMatchers.any -import org.mockito.ArgumentMatchers.eq -import org.mockito.Mockito.never -import org.mockito.Mockito.verify - -/** - * Unit test for [TrustPage]. - */ -class TrustPageTest : WebPageTest(::TrustPage) { - - @Test - fun `page returns correct path`() { - assertThat(page.path, equalTo("trust.html")) - } - - @Test - fun `page requires login`() { - assertThat(page.requiresLogin(), equalTo(true)) - } - - @Test - fun `page returns correct title`() { - addTranslation("Page.Trust.Title", "title trust page") - assertThat(page.getPageTitle(soneRequest), equalTo("title trust page")) - } - - @Test - fun `get method does not redirect`() { - verifyNoRedirect { } - } - - @Test - fun `post request without sone redirects to return page`() { - setMethod(POST) - addHttpRequestPart("returnPage", "return.html") - verifyRedirect("return.html") { - verify(core, never()).trustSone(eq(currentSone), any()) - } - } - - @Test - fun `post request with missing sone redirects to return page`() { - setMethod(POST) - addHttpRequestPart("returnPage", "return.html") - addHttpRequestPart("sone", "sone-id") - verifyRedirect("return.html") { - verify(core, never()).trustSone(eq(currentSone), any()) - } - } - - @Test - fun `post request with existing sone trusts the identity and redirects to return page`() { - setMethod(POST) - addHttpRequestPart("returnPage", "return.html") - addHttpRequestPart("sone", "sone-id") - val sone = mock() - addSone("sone-id", sone) - verifyRedirect("return.html") { - verify(core).trustSone(eq(currentSone), eq(sone)) - } - } - - @Test - fun `page can be created by dependency injection`() { - assertThat(baseInjector.getInstance(), notNullValue()) - } - -} diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/UntrustPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/UntrustPageTest.kt deleted file mode 100644 index eb0ebdd..0000000 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/UntrustPageTest.kt +++ /dev/null @@ -1,80 +0,0 @@ -package net.pterodactylus.sone.web.pages - -import net.pterodactylus.sone.data.* -import net.pterodactylus.sone.test.getInstance -import net.pterodactylus.sone.test.mock -import net.pterodactylus.sone.web.* -import net.pterodactylus.util.web.Method.* -import org.hamcrest.MatcherAssert.* -import org.hamcrest.Matchers.* -import org.junit.* -import org.mockito.ArgumentMatchers.any -import org.mockito.ArgumentMatchers.eq -import org.mockito.Mockito.never -import org.mockito.Mockito.verify - -/** - * Unit test for [UntrustPage]. - */ -class UntrustPageTest : WebPageTest(::UntrustPage) { - - @Test - fun `page returns correct path`() { - assertThat(page.path, equalTo("untrust.html")) - } - - @Test - fun `page requires login`() { - assertThat(page.requiresLogin(), equalTo(true)) - } - - @Test - fun `page returns correct title`() { - addTranslation("Page.Untrust.Title", "untrust page title") - assertThat(page.getPageTitle(soneRequest), equalTo("untrust page title")) - } - - @Test - fun `get request does not redirect`() { - verifyNoRedirect { - verify(core, never()).untrustSone(eq(currentSone), any()) - } - } - - @Test - fun `post request without sone parameter does not untrust but redirects`() { - setMethod(POST) - addHttpRequestPart("returnPage", "return.html") - verifyRedirect("return.html") { - verify(core, never()).untrustSone(eq(currentSone), any()) - } - } - - @Test - fun `post request with invalid sone parameter does not untrust but redirects`() { - setMethod(POST) - addHttpRequestPart("returnPage", "return.html") - addHttpRequestPart("sone", "no-sone") - verifyRedirect("return.html") { - verify(core, never()).untrustSone(eq(currentSone), any()) - } - } - - @Test - fun `post request with valid sone parameter untrusts and redirects`() { - setMethod(POST) - addHttpRequestPart("returnPage", "return.html") - addHttpRequestPart("sone", "sone-id") - val sone = mock() - addSone("sone-id", sone) - verifyRedirect("return.html") { - verify(core).untrustSone(currentSone, sone) - } - } - - @Test - fun `page can be created by dependency injection`() { - assertThat(baseInjector.getInstance(), notNullValue()) - } - -}