@@ -1876,19 +1876,30 @@ public void testGenerateNameIdWithoutFormat() throws URISyntaxException, IOExcep
18761876 assertEquals (expectedNameId , nameId );
18771877 }
18781878
1879+ /**
1880+ * Tests the generateUniqueID method
1881+ *
1882+ * * @see com.onelogin.saml2.util.Util#generateUniqueID
1883+ */
1884+ @ Test
1885+ public void testGenerateUniqueID () {
1886+ String s1 = Util .generateUniqueID ();
1887+ assertThat (s1 , startsWith (Util .UNIQUE_ID_PREFIX ));
1888+ }
1889+
18791890 /**
18801891 * Tests the generateUniqueID method
18811892 *
18821893 * @see com.onelogin.saml2.util.Util#generateUniqueID
18831894 */
18841895 @ Test
1885- public void testGenerateUniqueID () {
1886- String s1 = Util .generateUniqueID (Saml2Settings . DEFAULT_UNIQUE_ID_PREFIX );
1896+ public void testGenerateUniqueID_withCustomPrefix () {
1897+ String s1 = Util .generateUniqueID (Util . UNIQUE_ID_PREFIX );
18871898
1888- assertThat (s1 , startsWith (Saml2Settings . DEFAULT_UNIQUE_ID_PREFIX ));
1899+ assertThat (s1 , startsWith (Util . UNIQUE_ID_PREFIX ));
18891900 assertTrue (s1 .length () > 40 );
18901901
1891- String s2 = Util .generateUniqueID (Saml2Settings . DEFAULT_UNIQUE_ID_PREFIX );
1902+ String s2 = Util .generateUniqueID (Util . UNIQUE_ID_PREFIX );
18921903 String s3 = Util .generateUniqueID ("_" );
18931904 assertThat (s3 , startsWith ("_" ));
18941905
@@ -1898,19 +1909,21 @@ public void testGenerateUniqueID() {
18981909 }
18991910
19001911 /**
1901- * Tests that generateUniqueID method throws when given null
1912+ * Tests that generateUniqueID method uses default prefix when given null
19021913 */
1903- @ Test (expected =IllegalArgumentException .class )
1904- public void testGenerateUniqueID_throwsOnNullPrefix () {
1905- Util .generateUniqueID (null );
1914+ @ Test
1915+ public void testGenerateUniqueID_usesDefaultOnNull () {
1916+ String s1 = Util .generateUniqueID (null );
1917+ assertThat (s1 , startsWith (Util .UNIQUE_ID_PREFIX ));
19061918 }
19071919
19081920 /**
1909- * Tests that generateUniqueID method throws when given empty String
1921+ * Tests that generateUniqueID method uses default prefix when given empty String
19101922 */
1911- @ Test (expected =IllegalArgumentException .class )
1912- public void testGenerateUniqueID_throwsOnEmptyPrefix () {
1913- Util .generateUniqueID ("" );
1923+ @ Test
1924+ public void testGenerateUniqueID_usesDefaultOnEmpty () {
1925+ String s1 = Util .generateUniqueID ("" );
1926+ assertThat (s1 , startsWith (Util .UNIQUE_ID_PREFIX ));
19141927 }
19151928
19161929 /**
0 commit comments