Refine search
public void testSubClassEquals() { Credentials creds = new Credentials("user", "pass"); assertEquals(creds, new Credentials("user", "pass") { }); } }
public void testWhenCredentialsAlreadyPresentReturnsSame() { @SuppressWarnings("unchecked") Map<String, Credentials> credstore = createMock(Map.class); Credentials expected = new Credentials("root", null); ValueOfConfigurationKeyOrNull config = createMock(ValueOfConfigurationKeyOrNull.class); expect(credstore.containsKey("image")).andReturn(true); expect(credstore.get("image")).andReturn(expected); replay(config); replay(credstore); GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull fn = new GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull( "provider", config, credstore); assertEquals(fn.get(), expected); verify(config); verify(credstore); }
@Test public void testWithSingleDomainname() { LoginResponse response = createMock(LoginResponse.class); SessionClient client = createMock(SessionClient.class); expect(client.loginUserInDomainWithHashOfPassword(eq("User"), eq("Domain"), (String) anyObject())).andReturn(response); replay(client); LoginWithPasswordCredentials obj = new LoginWithPasswordCredentials(client); Credentials cred = new Credentials("Domain/User", "koffiedik"); obj.load(cred); }
public void testDefaultDifferentAcrossMultipleInjectors() throws IOException { Injector injector = createInjector(); Map<String, ByteSource> map = getMap(injector); put(map, getStore(injector), "test", new Credentials("user", "pass")); Map<String, Credentials> anotherStore = getStore(createInjector()); assertEquals(anotherStore.size(), 0); assertFalse(anotherStore.containsKey("test")); }
/** * We do not support just supplying the projectNumber, as this causes confusion when using oauth. OAuth JWT requires * the whole email for the ISS field. This is better than confusing users with instructions like "Use the email, * except if using bearer token. Then, you don't need the entire email, just put in the numeric id part of it." */ public void justProjectIdIsInvalid() throws Exception { server.enqueue(jsonResponse("/project.json")); try { fn().apply(new Credentials(projectNumber, credential)); fail(); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), String.format("Client email %s is malformed. Should be %s", projectNumber, new GoogleComputeEngineApiMetadata().getIdentityName())); } assertEquals(server.getRequestCount(), 0); }
@BeforeTest protected void setUpInjector() throws IOException { utils = FormSignerTest.injector(new Credentials("identity", "credential")).getInstance(AWSUtils.class); command = createMock(HttpCommand.class); expect(command.getCurrentRequest()).andReturn(createMock(HttpRequest.class)).atLeastOnce(); replay(command); }
public void testCredentialsAreLoadedOnRightAlgoAndCredentials() { Properties propertied = OAuthTestUtils.defaultProperties(new Properties()); Credentials validCredentials = new Credentials(propertied.getProperty("oauth.identity"), propertied.getProperty("oauth.credential")); PrivateKeySupplier supplier = new PrivateKeySupplier(Suppliers.ofInstance(validCredentials), new PrivateKeyForCredentials()); assertNotNull(supplier.get()); }
@SuppressWarnings("unchecked") public T build() { return (T) new Credentials(identity, credential); } }
@SuppressWarnings("unchecked") @Override public ComputeServiceContext load(URI from) { Properties props = new Properties(); props.putAll(projectProvider.get().getProperties()); Set<Module> modules = ImmutableSet.<Module> of(new AntLoggingModule(projectProvider.get(), ComputeServiceConstants.COMPUTE_LOGGER), new JschSshClientModule()); // adding the properties to the factory will allow us to pass // alternate endpoints String provider = from.getHost(); Credentials creds = Credentials.parse(from); return ContextBuilder.newBuilder(provider) .credentials(creds.identity, creds.credential) .modules(modules) .overrides(props).buildView(ComputeServiceContext.class); }
public void testWhenCredentialsAlreadyPresentReturnsSame() { @SuppressWarnings("unchecked") Map<String, Credentials> credstore = createMock(Map.class); Credentials expected = new Credentials("root", null); ValueOfConfigurationKeyOrNull config = createMock(ValueOfConfigurationKeyOrNull.class); expect(credstore.containsKey("image")).andReturn(true); expect(credstore.get("image")).andReturn(expected); replay(config); replay(credstore); GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull fn = new GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull( "provider", config, credstore); assertEquals(fn.get(), expected); verify(config); verify(credstore); }
@Test public void testWithNoDomainname() { LoginResponse response = createMock(LoginResponse.class); SessionClient client = createMock(SessionClient.class); expect(client.loginUserInDomainWithHashOfPassword(eq("User"), eq(""), (String) anyObject())).andReturn(response); replay(client); LoginWithPasswordCredentials obj = new LoginWithPasswordCredentials(client); Credentials cred = new Credentials("User", "koffiedik"); obj.load(cred); } }
@BeforeTest protected void setUpInjector() throws IOException { utils = FormSignerV2Test.injector(new Credentials("identity", "credential")).getInstance(AWSUtils.class); command = createMock(HttpCommand.class); expect(command.getCurrentRequest()).andReturn(createMock(HttpRequest.class)).atLeastOnce(); replay(command); }
@SuppressWarnings("unchecked") public T build() { return (T) new Credentials(identity, credential); } }
public void testWhenCredentialsNotPresentAndProviderPropertyHasUser() { @SuppressWarnings("unchecked") Map<String, Credentials> credstore = createMock(Map.class); Credentials expected = new Credentials("ubuntu", null); ValueOfConfigurationKeyOrNull config = createMock(ValueOfConfigurationKeyOrNull.class); expect(credstore.containsKey("image")).andReturn(false); expect(config.apply("provider.image.login-user")).andReturn("ubuntu"); expect(config.apply("provider.image.authenticate-sudo")).andReturn(null); expect(config.apply("jclouds.image.authenticate-sudo")).andReturn(null); expect(credstore.put("image", expected)).andReturn(null); replay(config); replay(credstore); GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull fn = new GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull( "provider", config, credstore); assertEquals(fn.get(), expected); verify(config); verify(credstore); }
public void testSubClassEquals() { Credentials creds = new Credentials("user", "pass"); assertEquals(creds, new Credentials("user", "pass") { }); } }
@Test public void testWithSingleDomainname() { LoginResponse response = createMock(LoginResponse.class); SessionApi client = createMock(SessionApi.class); expect(client.loginUserInDomainWithHashOfPassword(eq("User"), eq("Domain"), (String) anyObject())).andReturn(response); replay(client); LoginWithPasswordCredentials obj = new LoginWithPasswordCredentials(client); Credentials cred = new Credentials("Domain/User", "koffiedik"); obj.load(cred); }
@SuppressWarnings("unchecked") public T build() { return (T) new Credentials(identity, credential); } }
public void testWhenCredentialsNotPresentAndProviderPropertyHasUserAndPassword() { @SuppressWarnings("unchecked") Map<String, Credentials> credstore = createMock(Map.class); Credentials expected = new Credentials("ubuntu", "password"); ValueOfConfigurationKeyOrNull config = createMock(ValueOfConfigurationKeyOrNull.class); expect(credstore.containsKey("image")).andReturn(false); expect(config.apply("provider.image.login-user")).andReturn("ubuntu:password"); expect(config.apply("provider.image.authenticate-sudo")).andReturn(null); expect(config.apply("jclouds.image.authenticate-sudo")).andReturn(null); expect(credstore.put("image", expected)).andReturn(null); replay(config); replay(credstore); GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull fn = new GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull( "provider", config, credstore); assertEquals(fn.get(), expected); verify(config); verify(credstore); }
@Test public void testProviderMetadataWithCredentialsSetSupplier() { ContextBuilder withCredsSupplier = testContextBuilder().credentialsSupplier( ofInstance(new Credentials("foo", "BAR"))); Credentials creds = withCredsSupplier.buildInjector() .getInstance(Key.get(new TypeLiteral<Supplier<Credentials>>() { }, Provider.class)).get(); assertEquals(creds, new Credentials("foo", "BAR")); }
@Test public void testWithNoDomainname() { LoginResponse response = createMock(LoginResponse.class); SessionApi client = createMock(SessionApi.class); expect(client.loginUserInDomainWithHashOfPassword(eq("User"), eq(""), (String) anyObject())).andReturn(response); replay(client); LoginWithPasswordCredentials obj = new LoginWithPasswordCredentials(client); Credentials cred = new Credentials("User", "koffiedik"); obj.load(cred); } }