Skip to content

Instantly share code, notes, and snippets.

@jonathanvila
Created July 16, 2019 22:47
Show Gist options
  • Save jonathanvila/103125de42472bc628ee2c658f2e01e4 to your computer and use it in GitHub Desktop.
Save jonathanvila/103125de42472bc628ee2c658f2e01e4 to your computer and use it in GitHub Desktop.
@Test
public void mainRouteBuilder_getRHIdentity_ContentGiven_ShouldAddHeadersAndReturnOriginalObjectEnriched() throws Exception {
//Given
String x_rh_identity= Base64.getEncoder().encodeToString("{\"entitlements\":{\"insights\":{\"is_entitled\":true},\"openshift\":{\"is_entitled\":true},\"smart_management\":{\"is_entitled\":false},\"hybrid_cloud\":{\"is_entitled\":true}},\"identity\":{\"internal\":{\"auth_time\":0,\"auth_type\":\"jwt-auth\",\"org_id\":\"6340056\"},\"account_number\":\"1460290\",\"user\":{\"first_name\":\"Marco\",\"is_active\":true,\"is_internal\":true,\"last_name\":\"Rizzi\",\"locale\":\"en_US\",\"is_org_admin\":false,\"username\":\"mrizzi@redhat.com\",\"email\":\"mrizzi+qa@redhat.com\"},\"type\":\"User\"}}".getBytes());
String filename = "mificherito.txt";
Map<String, Object> headers = new HashMap<>();
Map<String, String> ma_metadata = new HashMap<>();
ma_metadata.put("customerid", "8899");
headers.put("MA_metadata", ma_metadata);
String rhIdentity = mainRouteBuilder.getRHIdentity(x_rh_identity, filename, headers);
String rhIdentityExpected = "{\"entitlements\":{\"insights\":{\"is_entitled\":true},\"openshift\":{\"is_entitled\":true},\"smart_management\":{\"is_entitled\":false},\"hybrid_cloud\":{\"is_entitled\":true}},\"identity\":{\"internal\":{\"auth_time\":0,\"auth_type\":\"jwt-auth\",\"org_id\":\"6340056\",\"filename\":\"mificherito.txt\",\"customerid\":\"8899\"},\"account_number\":\"1460290\",\"user\":{\"first_name\":\"Marco\",\"is_active\":true,\"is_internal\":true,\"last_name\":\"Rizzi\",\"locale\":\"en_US\",\"is_org_admin\":false,\"username\":\"mrizzi@redhat.com\",\"email\":\"mrizzi+qa@redhat.com\"},\"type\":\"User\"}}";
assertThat(new String(Base64.getDecoder().decode(rhIdentity))).isEqualToIgnoringCase(rhIdentityExpected);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment