@Before public void setUp() throws Exception { FAKE_TOKEN.setAppId("12345"); FAKE_TOKEN.setOwnerId("someowner"); FAKE_TOKEN.setViewerId("someowner"); converter = new BeanJsonConverter(Guice.createInjector()); request = new BaseRequestItem(Maps.<String, String[]>newHashMap(), FAKE_TOKEN, converter, converter); }
/** * Tests getPerson with a UserId typed as Viewerid. The Id string is set in the token in the field * viewerId. * * @throws Exception */ @Test public void testGetExpectedPersonByViewerId() throws Exception { SecurityToken token = FakeGadgetToken.createToken("viewerId=john.doe"); Future<Person> selectedObject = personService.getPerson(VIEWER, Collections.<String>emptySet(), token); Person person = selectedObject.get(); assertEquals(JOHN_DOE.getUserId(), person.getId()); }
@Test public void testGetAppId() throws Exception { request.setParameter("appId", "100"); assertEquals("100", request.getAppId()); request.setParameter("appId", "@app"); assertEquals(FAKE_TOKEN.getAppId(), request.getAppId()); }
@Before public void setUp() { cacheProvider = new LruCacheProvider(100); cache = new DefaultHttpCache(cacheProvider); service = new DefaultInvalidationService(cache, cacheProvider, new AtomicLong()); appxToken = new FakeGadgetToken(); appxToken.setAppId("AppX"); appxToken.setOwnerId("OwnerX"); appxToken.setViewerId("ViewerX"); appyToken = new FakeGadgetToken(); appyToken.setAppId("AppY"); appyToken.setOwnerId("OwnerY"); appyToken.setViewerId("ViewerY"); signedRequest = new HttpRequest(URI); signedRequest.setAuthType(AuthType.SIGNED); signedRequest.setSecurityToken(appxToken); signedRequest.setOAuthArguments(new OAuthArguments()); signedRequest.getOAuthArguments().setUseToken(OAuthArguments.UseToken.NEVER); signedRequest.getOAuthArguments().setSignOwner(true); signedRequest.getOAuthArguments().setSignViewer(true); fetcher = new DefaultRequestPipelineTest.FakeHttpFetcher(); oauth = new DefaultRequestPipelineTest.FakeOAuthRequestProvider(); requestPipeline = new DefaultRequestPipeline( fetcher, cache, oauth, new DefaultResponseRewriterRegistry(null, null), service, new HttpResponseMetadataHelper()); }