From 2e962b2f53a6827d5dbc3466d1fa76e13b1a077c Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Mon, 16 Nov 2020 12:31:31 +0100
Subject: [PATCH] no need to hardcode attributes list

---
 templates/other/accounts.php.tt2               | 5 ++---
 templates/web/renater/create_accounts.tt2.html | 4 ++--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/templates/other/accounts.php.tt2 b/templates/other/accounts.php.tt2
index 04acc33..2baf9e1 100644
--- a/templates/other/accounts.php.tt2
+++ b/templates/other/accounts.php.tt2
@@ -9,9 +9,8 @@ $validTestAccounts = array (
     '[% account.internal_uid() %]:{SHA256}[% account.password_hash() %]=' => array(
         'internal_uid' => array([% account.internal_uid().quote %]),
         'associatedSP' => array([% account.entityid().quote %]),
-    [% FOREACH attribute IN [ 'cn', 'displayName', 'givenName', 'sn', 'mail', 'schacHomeOrganization', 'schacHomeOrganizationType', 'eduPersonPrincipalName', 'eduPersonAffiliation', 'eduPersonScopedAffiliation' ] %]
-	[% NEXT UNLESS  attributes.$attribute %]
-        '[% attribute %]' => array([% attributes.$attribute.quote("'").join(', ') %]),
+    [% FOREACH pair IN attributes.pairs %]
+        '[% pair.key %]' => array([% pair.value.quote("'").join(', ') %]),
     [% END %]
     ),
 
diff --git a/templates/web/renater/create_accounts.tt2.html b/templates/web/renater/create_accounts.tt2.html
index 307e4f5..f139c28 100644
--- a/templates/web/renater/create_accounts.tt2.html
+++ b/templates/web/renater/create_accounts.tt2.html
@@ -58,9 +58,9 @@
         <div>
             <table>
                 <caption>[% lh.maketext("List of user attributes") %]</caption>
-    [% FOREACH attribute IN [ 'cn', 'displayName', 'givenName', 'sn', 'mail', 'schacHomeOrganization', 'schacHomeOrganizationType', 'eduPersonPrincipalName', 'eduPersonAffiliation', 'eduPersonScopedAffiliation' ] %]
+    [% FOREACH pair IN attributes.pairs %]
                 <tr>
-                    <th>[% attribute %]</th><td>[% attributes.$attribute.join(', ') %]</td>
+                    <th>[% pair.key %]</th><td>[% pair.value.join(', ') %]</td>
                 </tr>
     [% END %]
                 <tr>
-- 
GitLab