Removed strayed code fragment
[strongswan.git] / src / charon / plugins / unit_tester / tests / test_auth_info.c
index 1719190..d6abe7a 100644 (file)
 
 #include <daemon.h>
 #include <library.h>
-#include <credentials/auth_info.h>
+#include <config/auth_cfg.h>
 
 
-char buf[] = {0x01,0x02,0x03,0x04};
-chunk_t chunk = chunk_from_buf(buf);
-char certbuf[] = {
+static chunk_t certchunk = chunk_from_chars(
        0x30,0x82,0x02,0xfa,0x30,0x82,0x01,0xe2,0xa0,0x03,0x02,0x01,0x02,0x02,0x10,0x5a,
        0xf2,0x65,0xae,0x78,0xff,0x23,0xde,0xf7,0xa6,0xa3,0x94,0x8c,0x3f,0xa0,0xc1,0x30,
        0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x39,
@@ -69,21 +67,20 @@ char certbuf[] = {
        0xec,0xd2,0x31,0xc6,0x1e,0xb6,0xc0,0x57,0xd9,0xe1,0x14,0x06,0x9b,0xf8,0x51,0x69,
        0x47,0xf0,0x9c,0xcd,0x69,0xef,0x8e,0x5f,0x62,0xda,0x10,0xf7,0x3c,0x6d,0x0f,0x33,
        0xec,0x6f,0xfd,0x94,0x07,0x16,0x41,0x32,0x06,0xa4,0xe1,0x08,0x31,0x87,
-};
-chunk_t certchunk = chunk_from_buf(certbuf);
+);
 
 /*******************************************************************************
  * auth info test
  ******************************************************************************/
-bool test_auth_info()
+bool test_auth_cfg()
 {
-       auth_info_t *auth = auth_info_create(), *auth2;
+       auth_cfg_t *auth = auth_cfg_create(), *auth2;
        certificate_t *c1, *c2;
        enumerator_t *enumerator;
        int round = 0;
        void *value;
-       auth_item_t type;
-       
+       auth_rule_t type;
+
        c1 = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
                                                        BUILD_BLOB_ASN1_DER, certchunk,
                                                        BUILD_END);
@@ -91,9 +88,10 @@ bool test_auth_info()
        {
                return FALSE;
        }
-       
-       auth->add_item(auth, AUTHN_SUBJECT_CERT, c1);
-       if (!auth->get_item(auth, AUTHN_SUBJECT_CERT, (void**)&c2))
+
+       auth->add(auth, AUTH_RULE_SUBJECT_CERT, c1->get_ref(c1));
+       c2 = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
+       if (!c2)
        {
                return FALSE;
        }
@@ -101,33 +99,33 @@ bool test_auth_info()
        {
                return FALSE;
        }
-       
-       enumerator = auth->create_item_enumerator(auth);
+
+       enumerator = auth->create_enumerator(auth);
        while (enumerator->enumerate(enumerator, &type, &value))
        {
                round++;
-               if (round == 1 && type == AUTHN_SUBJECT_CERT && value == c1)
+               if (round == 1 && type == AUTH_RULE_SUBJECT_CERT && value == c1)
                {
                        continue;
                }
                return FALSE;
        }
        enumerator->destroy(enumerator);
-       
-       auth2 = auth_info_create();
-       auth2->add_item(auth2, AUTHN_CA_CERT, c1);
-       auth2->merge(auth2, auth);
-       
+
+       auth2 = auth_cfg_create();
+       auth2->add(auth2, AUTH_RULE_CA_CERT, c1->get_ref(c1));
+       auth2->merge(auth2, auth, FALSE);
+
        round = 0;
-       enumerator = auth2->create_item_enumerator(auth2);
+       enumerator = auth2->create_enumerator(auth2);
        while (enumerator->enumerate(enumerator, &type, &value))
        {
                round++;
-               if (round == 1 && type == AUTHN_CA_CERT && value == c1)
+               if (round == 1 && type == AUTH_RULE_CA_CERT && value == c1)
                {
                        continue;
                }
-               if (round == 2 && type == AUTHN_SUBJECT_CERT && value == c1)
+               if (round == 2 && type == AUTH_RULE_SUBJECT_CERT && value == c1)
                {
                        continue;
                }