You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by "Kalle Korhonen (JIRA)" <ji...@apache.org> on 2009/09/04 06:24:57 UTC

[jira] Created: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Add meaningful integration tests to assert key web functionality
----------------------------------------------------------------

                 Key: SHIRO-96
                 URL: https://issues.apache.org/jira/browse/SHIRO-96
             Project: Shiro
          Issue Type: Test
          Components: Authentication (log-in)
    Affects Versions: 1.0
         Environment: any
            Reporter: Kalle Korhonen
             Fix For: 1.0


Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770150#action_12770150 ] 

Les Hazlewood commented on SHIRO-96:
------------------------------------

Interesting - I noticed that when calling addToStrongReferences in the get method, if you call get 100 times with the same key, it will effectively expunge any other strong reference and the queue will contain 100 entries, all with the same memory pointer.  Not really desirable.

I think we might need to remove the addToStrongReferences method call from the get method and call trimStrongReferencesIfNecessary in any method that modifies the underlying Map.  I don't know why Heinz and Sydney did that in their initial implementation - I'll have to ask them.

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Kalle Korhonen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751531#action_12751531 ] 

Kalle Korhonen commented on SHIRO-96:
-------------------------------------

Thanks for applying. Yes, I bet the test is failing because of the same issue I mentioned above. The problem of course with these high level tests is that while they cover a lot of ground they don't tell you exactly where the problem is, just that there is a problem. I'm sure you have other things to do as well, but I think the test demonstrates an issue in the shiro-core itself. When things happen "fast enough" Shiro fails to initialize properly  (I think). The test code itself is very simple and seems to work more reliably when I run it via Maven but fails frequently when running via Eclipse. I was hoping that maybe you could run this test in your own IDE and see what you get - and if it would fail, it'd be perhaps easier for you to follow the stack trace and say "aha - the problem must be in CacheManager initialization because...." and I could take it from there. Right now it's been a bit like trying to find the needle from the haystack - eventually I'll probably find it with heavy use of the debugger but hoping to shortcut that process by extracting some domain knowledge from you.

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751574#action_12751574 ] 

Les Hazlewood commented on SHIRO-96:
------------------------------------

Sure, I'll be happy to help with this.  I'm on holiday until Tuesday, so I may or may not be able to look at it this weekend, but if I get some time, I'll try to debug.  This one will be fun ;)

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751471#action_12751471 ] 

Les Hazlewood commented on SHIRO-96:
------------------------------------

I had to comment out the logInAndRememberMe() test - it was failing from the command line.  Any ideas?

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Kalle Korhonen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12756703#action_12756703 ] 

Kalle Korhonen commented on SHIRO-96:
-------------------------------------

Took some time to debug this but couldn't get to the bottom of it. Have to move on for now, but it worries me and I'll have to come back to it some other time. I'll just update the issue with what I know. First of all, discovering tag libs doesn't seem to work correctly when the classes are not in jars (could be Eclipse specific problem). To be able to run in IDE and modify on the fly, I copied shiro.tld to to samples-web's src/main/webapp/WEB-INF and added:
	  <taglib>
	    <taglib-uri>http://shiro.apache.org/tags</taglib-uri>
	    <taglib-location>/WEB-INF/shiro.tld</taglib-location>
	  </taglib>
to its web.xml.

Either test randomly fails, more often in when running "slowly" with a debugger attached. It doesn't seem to be any of the the low level cache objects - I made them final one by one and returned pre-constructed map and it didn't make a difference. if (value != null)  on line 150 of SoftHashMap returns false when it won't work, indicating that two caches are initialized. However, log output for both a successful and a failing run are equal - up to a point where it fails with:
[org.apache.shiro.authc.AbstractAuthenticator]: Authentication attempt received for token [org.apache.shiro.authc.UsernamePasswordToken - root, rememberMe=false (/127.0.0.1)]
[org.apache.shiro.realm.AuthenticatingRealm]: No authentication information found for submitted authentication token [org.apache.shiro.authc.UsernamePasswordToken - root, rememberMe=false (/127.0.0.1)].  Returning null. A cache is populated in both cases.

Technically, it could be the container initialization as well since mvn jetty:run never seems to fail the same way, but I tried several options without any significant difference.



> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770132#action_12770132 ] 

Les Hazlewood commented on SHIRO-96:
------------------------------------

Actually SHIRO-49 is needed for a slightly different reason (in case Caching is disabled entirely, the 'memory-only' Realms should still work).  But by fixing that, we should see this issue go away as well.

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Kalle Korhonen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kalle Korhonen closed SHIRO-96.
-------------------------------

    Resolution: Fixed

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Kalle Korhonen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770138#action_12770138 ] 

Kalle Korhonen commented on SHIRO-96:
-------------------------------------

Agree and thanks for the explanations. Yes, I knew that wouldn't be the ultimate solution. Digging further into finding out why the value needs to exist in the cache in the first place would have been my next task, so you saved me a bunch of time and happy to learn that this issue is already on the radar. Adding to strong references in put makes sense to me and it solves the immediate problem with the test reliability so I'll do what I suggest to close this issue and we'll deal with SHIRO-49 separately.

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Kalle Korhonen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770099#action_12770099 ] 

Kalle Korhonen commented on SHIRO-96:
-------------------------------------

Ok, this is still preliminary but I think I was able to track it down and explain why the issue was so elusive. The problem (if I understand things correctly) is that we are not putting the value in strongReferences in SoftHashMap.put(). Normally, get() for the same key is called soon after during the Shiro initialization, but if garbage collection kicks in in between the entries are forever lost. If you add a call to addToStrongReferences(value); on line 252 right after putting it to the soft reference map then I could not make the test fail anymore. Les or anybody else interested, could you review whether this is the right solution? I can then put it in place and re-enable & clean up the tests.


> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Kalle Korhonen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770159#action_12770159 ] 

Kalle Korhonen commented on SHIRO-96:
-------------------------------------

Agree, likely not desirable. But I don't think we need to necessarily remove the call in get, but maybe the underlying strong references collection should have Set semantics (i.e. no duplicates) rather than simply a List/Queue. So maybe a LinkedHashSet. But then again, if you want to be super conservative about memory usage, maybe the idea was that the strong references should just keep the most used objects in memory rather than the last hundred and certainly, a hundred references to the same object will consume less memory than a hundred references to different objects. Anyway, we shouldn't deal with that as part of this issue - please ask the original authors and open a new issue for it (you can assign to me if you like) and I'll close this one (just re-enabled the tests in r829916).

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751464#action_12751464 ] 

Les Hazlewood commented on SHIRO-96:
------------------------------------

I applied the patch - thanks very much!

I'll leave this issue open in case you have any more ;)

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Kalle Korhonen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kalle Korhonen updated SHIRO-96:
--------------------------------

    Attachment: integration-tests.patch

Apply patch to root of samples-web

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHIRO-96) Add meaningful integration tests to assert key web functionality

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770130#action_12770130 ] 

Les Hazlewood commented on SHIRO-96:
------------------------------------

Hi Kalle,

I think you've definitely found the cause of the issues we're seeing with the test case, however, I think we're side-stepping the true cause of the problem by focusing on the SoftHashMap.

Adding in the call on line 252 per your suggestion would result in a little more deterministic behavior (and I certainly don't disagree to putting it in there), but it is not 'wrong' IMO to leave that line out:  it is intended that the map could indeed throw out GC'd values whenever the runtime feels like it, so 'losing' values is perfectly acceptable and so the existing implementation works as expected for memory-constrained caching.

Also, the default hard-reference retention size is 100, so it is possible that anything beyond that #, even with your addition, could still result in cache-miss behavior.

The real cause of the issues, at least I think, is that we're using a Cache to back non-transient account data.  In the case of a PropertiesRealm or IniRealm, we shouldn't be storing the constructed Account objects in a cache at all because a cache by nature won't necessarily guarantee data longevity.  I think we need to change those implementations to use a HashMap or ConcurrentHashMap so the values are never garbage-collected after construction for these 'memory-only' type of Realms.

And now that I remembered correctly, Alan opened SHIRO-49 for just this reason :)

> Add meaningful integration tests to assert key web functionality
> ----------------------------------------------------------------
>
>                 Key: SHIRO-96
>                 URL: https://issues.apache.org/jira/browse/SHIRO-96
>             Project: Shiro
>          Issue Type: Test
>          Components: Authentication (log-in)
>    Affects Versions: 1.0
>         Environment: any
>            Reporter: Kalle Korhonen
>             Fix For: 1.0
>
>         Attachments: integration-tests.patch
>
>
> Related to SHIRO-93 (but you closed it already - could have re-opened as well). Assert login/logout and remember me functionality. Also updating htmlunit to newly released 2.6. Note that tests revealed an interesting thread-safety issue: sometimes getAuthorizationCache().get(upToken.getUsername()); on line 141 of SimpleAccountRealm returned null, causing the authentication to fail. It happened much frequently when I was running the test via Eclipse, but couldn't get it to run when running via Maven. I took an initial look at the CacheManager and didn't follow through completely, but it looked like that a map initialization somewhere may not have been synchronized. Note that these tests run considerably faster than if a human was using a browser but otherwise they don't semantically do anything else different. A patch to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.