<div dir="ltr">Hi,<div><br></div><div>I agree w/ Erik - however, I think the test has a bug, if the installations are not directly associated with a Variant. Should be easy to fix.</div><div><br></div><div>BTW. qmx, you mentioned the "<span style="font-size:12.8000001907349px">setDeviceType()", but that is really just plain text metadata, like here:</span></div><div><a href="https://github.com/aerogear/aerogear-push-helloworld/blob/master/ios/HelloWorld/AGAppDelegate.m#L106">https://github.com/aerogear/aerogear-push-helloworld/blob/master/ios/HelloWorld/AGAppDelegate.m#L106</a> </div><div><br></div><div>The validator is triggered by the actual variant type (installation<span style="font-size:12.8000001907349px">.getVariant().</span><span style="font-size:12.8000001907349px">getType())</span></div><div><br></div><div>-Matthias</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 13, 2015 at 8:17 AM, Erik Jan de Wit <span dir="ltr"><<a href="mailto:edewit@redhat.com" target="_blank">edewit@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Don’t know if it’s really a bug, but in order to validate that a device token is valid we need to know what variant type it belongs to. It makes no sense for a installation to be persisted without a Variant, because then you cannot send any messages to that device. So if you try to persist a installation without a variant the device token is not valid seems to be to be a valid statement.<br>
<br>
This was introduced when we added cordova, there it’s easy to make a mistake and have the wrong variantID / secret in your settings. Resulting in a iOS device registering under an android variant. With the deviceToken validation this can no longer happen.<br>
<br>
Does this make sense?<br>
<br>
Cheers,<br>
Erik Jan<br>
<div class="HOEnZb"><div class="h5"><br>
On 13 Feb,2015, at 2:02 , Douglas Campos <<a href="mailto:qmx@qmx.me">qmx@qmx.me</a>> wrote:<br>
<br>
> Howdy!<br>
><br>
> I was doing the migration work and found out something funny:<br>
><br>
> For Installations, we have `installation.setDeviceType()`, but during<br>
> Installation `persist()`, the DeviceTokenValidator is called, which in<br>
> turn looks for a Variant.<br>
><br>
> So after fiddling with some orm settings suddenly a bunch of tests<br>
> started to break, which led me to this snippet[1]:<br>
><br>
> // disabled<br>
> Installation android3 = new Installation();<br>
> android3.setAlias("<a href="mailto:foo@bar.org">foo@bar.org</a>");<br>
> android3.setDeviceToken("543234234890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");<br>
> android3.setDeviceType("Android Tablet");<br>
> android3.setEnabled(false);<br>
><br>
> installationDao.create(android3);<br>
><br>
> See, our tests are creating an installation without associating it to a<br>
> variant first, then it blows up here[2]:<br>
><br>
> // DeviceTokenValidator#isValid()<br>
> if (installation.getVariant() == null || installation.getVariant().getType() == null || deviceToken == null) {<br>
> return false;<br>
> }<br>
><br>
> This is smelling like a bug to me - kinda like the validator wasn't<br>
> actually running during tests. Am I crazy?<br>
><br>
> [1]:<a href="https://github.com/aerogear/aerogear-unifiedpush-server/blob/master/model/jpa/src/test/java/org/jboss/aerogear/unifiedpush/jpa/InstallationDaoTest.java#L133-L140" target="_blank">https://github.com/aerogear/aerogear-unifiedpush-server/blob/master/model/jpa/src/test/java/org/jboss/aerogear/unifiedpush/jpa/InstallationDaoTest.java#L133-L140</a><br>
> [2]:<a href="https://github.com/aerogear/aerogear-unifiedpush-server/blob/master/model/api/src/main/java/org/jboss/aerogear/unifiedpush/api/validation/DeviceTokenValidator.java#L60" target="_blank">https://github.com/aerogear/aerogear-unifiedpush-server/blob/master/model/api/src/main/java/org/jboss/aerogear/unifiedpush/api/validation/DeviceTokenValidator.java#L60</a><br>
><br>
> --<br>
> qmx<br>
> _______________________________________________<br>
> aerogear-dev mailing list<br>
> <a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
<br>
<br>
_______________________________________________<br>
aerogear-dev mailing list<br>
<a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Matthias Wessendorf <br><br>blog: <a href="http://matthiaswessendorf.wordpress.com/" target="_blank">http://matthiaswessendorf.wordpress.com/</a><br>sessions: <a href="http://www.slideshare.net/mwessendorf" target="_blank">http://www.slideshare.net/mwessendorf</a><br>twitter: <a href="http://twitter.com/mwessendorf" target="_blank">http://twitter.com/mwessendorf</a></div>
</div>