mirror of https://github.com/shred/acme4j
				
				
				
			Add method to return profile description
							parent
							
								
									43b6a7c7c6
								
							
						
					
					
						commit
						83d6f38ec7
					
				| 
						 | 
				
			
			@ -155,6 +155,23 @@ public class Metadata {
 | 
			
		|||
                .isPresent();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns a description of the requested profile. This can be a human-readable string
 | 
			
		||||
     * or a URL linking to a documentation.
 | 
			
		||||
     * <p>
 | 
			
		||||
     * Empty if the profile is not allowed.
 | 
			
		||||
     *
 | 
			
		||||
     * @since 3.5.0
 | 
			
		||||
     */
 | 
			
		||||
    public Optional<String> getProfileDescription(String profile) {
 | 
			
		||||
        return meta.get("profiles").optional()
 | 
			
		||||
                .map(Value::asObject)
 | 
			
		||||
                .orElseGet(JSON::empty)
 | 
			
		||||
                .get(profile)
 | 
			
		||||
                .optional()
 | 
			
		||||
                .map(Value::asString);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns whether the CA supports subdomain auth according to RFC9444.
 | 
			
		||||
     *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -185,7 +185,11 @@ public class SessionTest {
 | 
			
		|||
            softly.assertThat(meta.isAutoRenewalGetAllowed()).isTrue();
 | 
			
		||||
            softly.assertThat(meta.isProfileAllowed()).isTrue();
 | 
			
		||||
            softly.assertThat(meta.isProfileAllowed("classic")).isTrue();
 | 
			
		||||
            softly.assertThat(meta.isProfileAllowed("custom")).isTrue();
 | 
			
		||||
            softly.assertThat(meta.isProfileAllowed("invalid")).isFalse();
 | 
			
		||||
            softly.assertThat(meta.getProfileDescription("classic")).contains("The profile you're accustomed to");
 | 
			
		||||
            softly.assertThat(meta.getProfileDescription("custom")).contains("Some other profile");
 | 
			
		||||
            softly.assertThat(meta.getProfileDescription("invalid")).isEmpty();
 | 
			
		||||
            softly.assertThat(meta.isExternalAccountRequired()).isTrue();
 | 
			
		||||
            softly.assertThat(meta.isSubdomainAuthAllowed()).isTrue();
 | 
			
		||||
            softly.assertThat(meta.getJSON()).isNotNull();
 | 
			
		||||
| 
						 | 
				
			
			@ -240,6 +244,7 @@ public class SessionTest {
 | 
			
		|||
                    .isThrownBy(meta::isAutoRenewalGetAllowed);
 | 
			
		||||
            softly.assertThat(meta.isProfileAllowed()).isFalse();
 | 
			
		||||
            softly.assertThat(meta.isProfileAllowed("classic")).isFalse();
 | 
			
		||||
            softly.assertThat(meta.getProfileDescription("classic")).isEmpty();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue