{"action":"created","issue":{"url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/3486","repository_url":"https://api.github.com/repos/IdentityServer/IdentityServer3","labels_url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/3486/labels{/name}","comments_url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/3486/comments","events_url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/3486/events","html_url":"https://github.com/IdentityServer/IdentityServer3/issues/3486","id":203355062,"number":3486,"title":"Embedded Libraries / Mocking IndentityServer3","user":{"login":"marcpixelpin","id":25365195,"avatar_url":"https://avatars.githubusercontent.com/u/25365195?v=3","gravatar_id":"","url":"https://api.github.com/users/marcpixelpin","html_url":"https://github.com/marcpixelpin","followers_url":"https://api.github.com/users/marcpixelpin/followers","following_url":"https://api.github.com/users/marcpixelpin/following{/other_user}","gists_url":"https://api.github.com/users/marcpixelpin/gists{/gist_id}","starred_url":"https://api.github.com/users/marcpixelpin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcpixelpin/subscriptions","organizations_url":"https://api.github.com/users/marcpixelpin/orgs","repos_url":"https://api.github.com/users/marcpixelpin/repos","events_url":"https://api.github.com/users/marcpixelpin/events{/privacy}","received_events_url":"https://api.github.com/users/marcpixelpin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-26T12:03:48Z","updated_at":"2017-02-10T09:58:54Z","closed_at":"2017-02-10T09:58:54Z","body":"I'm using Moq to Mock our WebApplication for Unit Testing and I have found that IdentityServer3 crashes with \"Unable to cast object of type 'Autofac.Core.Lifetime.LifetimeScope' to type 'Autofac.ILifetimeScope'.\" - if I use the nuget package version. If I build my own version it works successfully.\r\n\r\nI have found the build.ps1 scripts that il-merge's the binaries, so I can understand that the returned lifetime scope is the wrong one - I believe I understand the error and have read https://github.com/IdentityServer/IdentityServer3/issues/1332\r\n\r\nThe application runs successfully with the NuGet package or the clean build, it is just the Unit Test that fails, using IL-Spy to disassemble the nuget package highlighted the embedded dll's\r\n\r\nI can't find the reason the libraries are embedded, is this to do with security of the library and would using a clean build cause any security issues?\r\n\r\nI'm using this code to start the Unit Test so this may be the issue?\r\n\r\n[code]\r\n\r\n            builder.RegisterInstance(MockPPGeoWebService.Object).SingleInstance();\r\n\r\n            Utility._container = builder.Build();\r\n\r\n            ILifetimeScope scope = Utility._container.BeginLifetimeScope();\r\n\r\n            // dictionary for the OwinContext\r\n            IDictionary<string, string> cookieDictionary = new Dictionary<string, string>()\r\n            {\r\n                {\"SignInMessage.signin\", Convert.ToBase64String(Encoding.UTF8.GetBytes(\"{\\\"clientid\\\": \\\"cool\\\"}\"))}\r\n            };\r\n            Dictionary<string, object> owinEnvironment = new Dictionary<string, object>()\r\n            {\r\n                { \"owin.RequestHeaders\", new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase) },\r\n                { \"owin.ResponseHeaders\", new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase) },\r\n                { \"idsvr:autofac:OwinLifetimeScope\", scope },\r\n                { \"Microsoft.Owin.Cookies#dictionary\", cookieDictionary },\r\n            };\r\n\r\n            // This allows Owin to bootstrap its OwinContext from the dictionary\r\n            MockHttpContext.SetupGet(x => x.Items[\"owin.Environment\"]).Returns(owinEnvironment);\r\n[/code]\r\n\r\nThanks,\r\n\r\nMarc\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/comments/278903358","html_url":"https://github.com/IdentityServer/IdentityServer3/issues/3486#issuecomment-278903358","issue_url":"https://api.github.com/repos/IdentityServer/IdentityServer3/issues/3486","id":278903358,"user":{"login":"marcpixelpin","id":25365195,"avatar_url":"https://avatars.githubusercontent.com/u/25365195?v=3","gravatar_id":"","url":"https://api.github.com/users/marcpixelpin","html_url":"https://github.com/marcpixelpin","followers_url":"https://api.github.com/users/marcpixelpin/followers","following_url":"https://api.github.com/users/marcpixelpin/following{/other_user}","gists_url":"https://api.github.com/users/marcpixelpin/gists{/gist_id}","starred_url":"https://api.github.com/users/marcpixelpin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcpixelpin/subscriptions","organizations_url":"https://api.github.com/users/marcpixelpin/orgs","repos_url":"https://api.github.com/users/marcpixelpin/repos","events_url":"https://api.github.com/users/marcpixelpin/events{/privacy}","received_events_url":"https://api.github.com/users/marcpixelpin/received_events","type":"User","site_admin":false},"created_at":"2017-02-10T09:58:54Z","updated_at":"2017-02-10T09:58:54Z","body":"I understand the difficulties of deployment - and yes it is time-consuming to get all the needed nuget packages working manually - I can see this is for convenience - but I've removed all the embedded libraries, which makes adding the library to a larger existing project more practical."}}
{"actor":{"display_login":"marcpixelpin"}}