use of com.cloudbees.plugins.credentials.domains.PathRequirement in project blueocean-plugin by jenkinsci.
the class BlueOceanCredentialsProviderTest method getCredentialsWhenUserExistedButNotAccessible.
@Test
@Issue("JENKINS-53188")
public void getCredentialsWhenUserExistedButNotAccessible() {
PowerMockito.mockStatic(Jenkins.class);
PowerMockito.when(Jenkins.get()).thenReturn(jenkins);
PowerMockito.when(Jenkins.get()).thenReturn(jenkins);
PowerMockito.when(Jenkins.get()).thenReturn(jenkins);
when(jenkins.getSecurityRealm()).thenReturn(SecurityRealm.NO_AUTHENTICATION);
when(jenkins.getSecretKey()).thenReturn("xxx");
PowerMockito.mockStatic(User.class);
// Make sure we return a user, cause it did once exist
PowerMockito.when(User.get(anyString(), anyBoolean(), any())).thenReturn(user);
Domain domain = BlueOceanCredentialsProvider.createDomain("api.github.com");
BlueOceanCredentialsProvider blueOceanCredentialsProvider = new BlueOceanCredentialsProvider();
BlueOceanCredentialsProvider.FolderPropertyImpl prop = new BlueOceanCredentialsProvider.FolderPropertyImpl("halkeye", "halkeye", domain);
when(folder.getProperties()).thenReturn(describableList);
when(describableList.get(BlueOceanCredentialsProvider.FolderPropertyImpl.class)).thenReturn(prop);
// Should be empty when trying to impersonate and grab credentials though
List<StandardUsernameCredentials> credentials = blueOceanCredentialsProvider.getCredentials(StandardUsernameCredentials.class, (ItemGroup) folder, ACL.SYSTEM, new ArrayList<>(Arrays.asList(new SchemeRequirement("https"), new HostnameRequirement("api.github.com"), new PathRequirement("/"))));
assertEquals(Collections.emptyList(), credentials);
List<Credentials> storeCredentials = prop.getStore().getCredentials(domain);
assertEquals(Collections.emptyList(), storeCredentials);
}
Aggregations