<commit_before>package irmaserver

import (
	"encoding/json"
	"testing"

	"github.com/privacybydesign/irmago/server"
	"github.com/stretchr/testify/require"
)

func TestAnonimizeRequest(t *testing.T) {
	req, err := server.ParseSessionRequest(`{"request":{"@context":"https://irma.app/ld/request/disclosure/v2","context":"AQ==","nonce":"MtILupG0g0J23GNR1YtupQ==","devMode":true,"disclose":[[[{"type":"test.test.email.email","value":"<EMAIL>"}]]]}}`)
	require.NoError(t, err)
	out, err := json.Marshal(purgeRequest(req))
	require.NoError(t, err)
	require.Equal(t, `{"validity":120,"request":{"@context":"https://irma.app/ld/request/disclosure/v2","context":"AQ==","nonce":"MtILupG0g0J23GNR1YtupQ==","devMode":true,"disclose":[[["test.test.email.email"]]]}}`, string(out))

	req, err = server.ParseSessionRequest(`{"request":{"@context":"https://irma.app/ld/request/issuance/v2","context":"AQ==","nonce":"wrmq+QY8r86nbGTI+mMAzg==","devMode":true,"disclose":[[["irma-demo.RU.studentCard.studentID"]]],"credentials":[{"validity":1633564800,"keyCounter":2,"credential":"irma-demo.RU.studentCard","attributes":{"level":"42","studentCardNumber":"31415927","studentID":"s1234567","university":"Radboud"}}],"disclose":[[[{"type":"test.test.email.email","value":"<EMAIL>"}]]]}}`)
	require.NoError(t, err)
	out, err = json.Marshal(purgeRequest(req))
	require.NoError(t, err)
	require.Equal(t, `{"validity":120,"request":{"@context":"https://irma.app/ld/request/issuance/v2","context":"AQ==","nonce":"wrmq+QY8r86nbGTI+mMAzg==","devMode":true,"disclose":[[["test.test.email.email"]]],"credentials":[{"validity":1633564800,"keyCounter":2,"credential":"irma-demo.RU.studentCard","attributes":null}]}}`, string(out))
}<commit_msg>test: fix expired credentials in issuance unit test<commit_after>package irmaserver

import (
	"encoding/json"
	"testing"

	"github.com/privacybydesign/irmago/server"
	"github.com/stretchr/testify/require"
)

func TestAnonimizeRequest(t *testing.T) {
	req, err := server.ParseSessionRequest(`{"request":{"@context":"https://irma.app/ld/request/disclosure/v2","context":"AQ==","nonce":"MtILupG0g0J23GNR1YtupQ==","devMode":true,"disclose":[[[{"type":"test.test.email.email","value":"<EMAIL>"}]]]}}`)
	require.NoError(t, err)
	out, err := json.Marshal(purgeRequest(req))
	require.NoError(t, err)
	require.Equal(t, `{"validity":120,"request":{"@context":"https://irma.app/ld/request/disclosure/v2","context":"AQ==","nonce":"MtILupG0g0J23GNR1YtupQ==","devMode":true,"disclose":[[["test.test.email.email"]]]}}`, string(out))

	req, err = server.ParseSessionRequest(`{"request":{"@context":"https://irma.app/ld/request/issuance/v2","context":"AQ==","nonce":"wrmq+QY8r86nbGTI+mMAzg==","devMode":true,"disclose":[[["irma-demo.RU.studentCard.studentID"]]],"credentials":[{"validity":2000000000,"keyCounter":2,"credential":"irma-demo.RU.studentCard","attributes":{"level":"42","studentCardNumber":"31415927","studentID":"s1234567","university":"Radboud"}}],"disclose":[[[{"type":"test.test.email.email","value":"<EMAIL>"}]]]}}`)
	require.NoError(t, err)
	out, err = json.Marshal(purgeRequest(req))
	require.NoError(t, err)
	require.Equal(t, `{"validity":120,"request":{"@context":"https://irma.app/ld/request/issuance/v2","context":"AQ==","nonce":"wrmq+QY8r86nbGTI+mMAzg==","devMode":true,"disclose":[[["test.test.email.email"]]],"credentials":[{"validity":2000000000,"keyCounter":2,"credential":"irma-demo.RU.studentCard","attributes":null}]}}`, string(out))
}
{'fraction_non_alphanumeric': 0.2608318890814558, 'fraction_numerical': 0.03755054881571346, 'mean_word_length': 11.825925925925926, 'pattern_counts': {'":': 90, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5429532', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1287, 'n_words': 79}