Exemplo n.º 1
0
Arquivo: Tests.cs Projeto: Vidisha/eb
        public Tests()
        {
            string baseDir = Directory.GetCurrentDirectory();
              Directory.SetCurrentDirectory(baseDir.Substring(0, baseDir.LastIndexOf("\\bin")));

              AdapterSettings adapterSettings = new AdapterSettings();
              adapterSettings.AppendSettings(new AppSettingsReader("App.config"));

              FileInfo log4netConfig = new FileInfo("Log4net.config");
              log4net.Config.XmlConfigurator.Configure(log4netConfig);

              _dataLayer = new ebDataLayer(adapterSettings);
              _scenarios = Utility.Read<Scenarios>("Scenarios.xml");
        }
Exemplo n.º 2
0
        public Tests()
        {
            string baseDir = Directory.GetCurrentDirectory();
              Directory.SetCurrentDirectory(baseDir.Substring(0, baseDir.LastIndexOf("\\bin")));

              AdapterSettings adapterSettings = new AdapterSettings();
              adapterSettings["ProjectName"] = project;
              adapterSettings["ApplicationName"] = app;

              string appConfigPath = string.Format("App_Data\\{0}.{1}.config", project, app);
              adapterSettings.AppendSettings(new AppSettingsReader(appConfigPath));

              _dataLayer = new SPPIDDataLayer(adapterSettings);
              _scenarios = org.iringtools.utility.Utility.Read<Scenarios>("Scenarios.xml");
        }
Exemplo n.º 3
0
 public async Task UpdateAsync(string id, Scenarios scenario)
 {
     await _scenarios.ReplaceOneAsync(s => s.Id == id, scenario);
 }
Exemplo n.º 4
0
        public PageFrontMenu()
        {
            InitializeComponent();

            StackPanel panelContent = new StackPanel();

            panelContent.Margin = new Thickness(10, 0, 10, 0);
            panelContent.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            panelContent.VerticalAlignment   = System.Windows.VerticalAlignment.Center;

            Panel panelLogo = UICreator.CreateGameLogo();

            panelLogo.Margin = new Thickness(0, 0, 0, 20);

            panelContent.Children.Add(panelLogo);

            Button btnNewGame = createMenuButton(Translator.GetInstance().GetString("PageFrontMenu", "200"));

            btnNewGame.Click += btnNewGame_Click;
            panelContent.Children.Add(btnNewGame);

            Button btnPlayScenario = createMenuButton(Translator.GetInstance().GetString("PageFrontMenu", "205"));

            btnPlayScenario.IsEnabled = Scenarios.GetNumberOfScenarios() > 0;
            btnPlayScenario.Click    += btnPlayScenario_Click;
            panelContent.Children.Add(btnPlayScenario);

            Button btnLoadGame = createMenuButton(Translator.GetInstance().GetString("PageFrontMenu", "201"));

            btnLoadGame.Click += btnLoadGame_Click;
            panelContent.Children.Add(btnLoadGame);

            Button btnSettings = createMenuButton(Translator.GetInstance().GetString("PageFrontMenu", "202"));

            btnSettings.Click    += btnSettings_Click;
            btnSettings.IsEnabled = false;
            panelContent.Children.Add(btnSettings);

            Button btnCredits = createMenuButton(Translator.GetInstance().GetString("PageFrontMenu", "203"));

            btnCredits.Click += btnCredits_Click;
            // btnCredits.IsEnabled = false;
            panelContent.Children.Add(btnCredits);

            Button btnExitGame = createMenuButton(Translator.GetInstance().GetString("PageFrontMenu", "204"));

            btnExitGame.Click += btnExitGame_Click;
            panelContent.Children.Add(btnExitGame);

            base.setTopMenu(new PageTopMenu());

            base.hideNavigator();

            base.hideBottomMenu();

            base.setContent(panelContent);

            base.setHeaderContent(Translator.GetInstance().GetString("PageFrontMenu", "1001"));

            showPage(this);
        }
Exemplo n.º 5
0
        protected int SetupScenarioList(int layerIndex)
        {
            // right side group
            RelativeRect rect = new RelativeRect(RelativeLoc.XRightBorder + RelativeLoc.BorderOffset, RelativeLoc.YUpper + RelativeLoc.BorderOffset, RelativeSize.TwoColumnWidth, RelativeSize.SevenEightsHeight, OriginLocation.UpperRight);

            GridLayoutGroup scenarioGrid = new GridLayoutGroup(rect, 15, 2);

            Columns[1] = scenarioGrid;

            scenarioGrid.MaxChildSize = MenuCommon.ButtonHeight.Paramater;

            scenarioGrid.SetColSpan(0, 1);
            scenarioGrid.SetColSpan(1, 6);
            scenarioGrid.SetColSpan(7, 4);
            scenarioGrid.SetColSpan(12, 3);

            // Scenario header
            scenarioGrid.AddChild(new Header(new RelativeRect(), MenuRes.Scenario));

            ButtonScrollList scenarioList = new ButtonScrollList(RelativeRect.Full);

            scenarioList.DesiredRows = 6;

            foreach (var scenario in Scenarios.GetScenarioList())
            {
                scenarioList.AddItem(scenario.Name, scenario);
            }

            scenarioList.SelectedIndexChanged += ScenarioList_SelectedIndexChanged;
            scenarioList.FillMode              = UIFillModes.Stretch4Quad;
            scenarioGrid.AddChild(scenarioList);


            SecenarioText = new TextArea(RelativeRect.Full, string.Empty, MenuManager.MainFont, ThemeManager.GetThemeAsset("ui/TextEntryBackground.png"));
            SecenarioText.DefaultMaterial.Color = Color.Gray;
            SecenarioText.DesiredRows           = 8;
            SecenarioText.BorderPadding         = 4;
            SecenarioText.MiniumElementHeight   = 20;

            scenarioGrid.AddChild(SecenarioText);

            // sensor scan complexity
            // get data from selected scenario
            scenarioGrid.AddChild(MakeGridLabel(MenuRes.Variation));
            VariationList = new SpinSelector(new RelativeRect(), MenuRes.DefaultVariation.Split(";".ToCharArray()), 0);
            VariationList.ValueChanged += ScenarioVariation_ValueChanged;
            scenarioGrid.AddChild(VariationList);

            // replace with variation info
            VariationText = new TextArea(RelativeRect.Full, string.Empty, MenuManager.MainFont, ThemeManager.GetThemeAsset("ui/TextEntryBackground.png"));
            VariationText.DefaultMaterial.Color = Color.Gray;
            VariationText.DesiredRows           = 6;
            VariationText.BorderPadding         = 4;
            VariationText.MiniumElementHeight   = 20;
            scenarioGrid.AddChild(VariationText);

            AddElement(Columns[1], layerIndex + 1);

            scenarioList.SetSelectedIndex(0);

            return(layerIndex + 1);
        }
Exemplo n.º 6
0
 internal static MockIdentifier GetMockIdentifier(Scenarios scenario, ProtocolVersion providerVersion)
 {
     return GetMockIdentifier(scenario, providerVersion, false);
 }
Exemplo n.º 7
0
 public static void GoToScenarioStaticMethod(Scenarios scenarios)
 {
     GoToScenario(scenarios);
 }
 public Scenario GetScenario(uint id) => Scenarios.ContainsKey(id) ? Scenarios[id] : null;
Exemplo n.º 9
0
        public void Refresh()
        {
            _objects = new Objects(_jee);

            if(_objects.Loaded)
            {
                _eqLogics = new EqLogics(_jee, this);

                if (_eqLogics.Loaded)
                {
                    _commands = new Commands(_jee, this);

                    if (_commands.Loaded)
                    {
                        _plugins = new Plugins(_jee);

                        if (_plugins.Loaded)
                        {
                            _scenarios = new Scenarios(_jee);

                            if (_scenarios.Loaded)
                            {
                                _messages = new Messages(_jee);

                                if (_messages.Loaded)
                                {
                                    _loaded = true;
                                }
                                else
                                {
                                    _error = _scenarios.Error;
                                    _loaded = false;
                                }
                            }
                            else
                            {
                                _error = _messages.Error;
                                _loaded = false;
                            }
                        }
                        else
                        {
                            _error = _plugins.Error;
                            _loaded = false;
                        }

                    }
                    else
                    {
                        _error = _commands.Error;
                        _loaded = false;
                    }
                }
                else
                {
                    _error = _eqLogics.Error;
                    _loaded = false;
                }
            }
            else
            {
                _error = _objects.Error;
                _loaded = false;
            }
        }
Exemplo n.º 10
0
 internal static void SetAuthenticationFromScenario(Scenarios scenario, DotNetOpenId.Provider.IAuthenticationRequest request)
 {
     Assert.IsTrue(request.IsReturnUrlDiscoverable);
     switch (scenario) {
         case TestSupport.Scenarios.ExtensionFullCooperation:
         case TestSupport.Scenarios.ExtensionPartialCooperation:
         case TestSupport.Scenarios.AutoApproval:
             // immediately approve
             request.IsAuthenticated = true;
             break;
         case TestSupport.Scenarios.AutoApprovalAddFragment:
             request.SetClaimedIdentifierFragment("frag");
             request.IsAuthenticated = true;
             break;
         case TestSupport.Scenarios.ApproveOnSetup:
             request.IsAuthenticated = !request.Immediate;
             break;
         case TestSupport.Scenarios.AlwaysDeny:
             request.IsAuthenticated = false;
             break;
         default:
             throw new InvalidOperationException("Unrecognized scenario");
     }
 }
Exemplo n.º 11
0
 public static Identifier GetDelegateUrl(Scenarios scenario)
 {
     return GetDelegateUrl(scenario, false);
 }
Exemplo n.º 12
0
 internal static UriIdentifier GetOPIdentityUrl(Scenarios scenario, bool useSsl)
 {
     var args = new Dictionary<string, string> {
         { "user", scenario.ToString() },
     };
     return new UriIdentifier(GetFullUrl("/" + OPDefaultPage, args, useSsl));
 }
Exemplo n.º 13
0
 internal static ServiceEndpoint GetServiceEndpoint(Scenarios scenario, ProtocolVersion providerVersion, int servicePriority, bool useSsl)
 {
     return ServiceEndpoint.CreateForClaimedIdentifier(
         GetIdentityUrl(scenario, providerVersion, useSsl),
         GetDelegateUrl(scenario, useSsl),
         GetFullUrl("/" + ProviderPage, null, useSsl),
         new string[] { Protocol.Lookup(providerVersion).ClaimedIdentifierServiceTypeURI },
         servicePriority,
         10
         );
 }
Exemplo n.º 14
0
    internal static MockIdentifier GetMockOPIdentifier(Scenarios scenario, UriIdentifier expectedClaimedId, bool useSslOpIdentifier, bool useSslProviderEndpoint)
    {
        var fields = new Dictionary<string, string> {
            { "user", scenario.ToString() },
        };
        Uri opEndpoint = GetFullUrl(DirectedProviderEndpoint, fields, useSslProviderEndpoint);
        Uri opIdentifier = GetOPIdentityUrl(scenario, useSslOpIdentifier);
        ServiceEndpoint se = ServiceEndpoint.CreateForProviderIdentifier(
            opIdentifier,
            opEndpoint,
            new string[] { Protocol.v20.OPIdentifierServiceTypeURI },
            10,
            10
            );

        // Register the Claimed Identifier that directed identity will choose so that RP
        // discovery on that identifier can be mocked up.
        MockHttpRequest.RegisterMockXrdsResponse(expectedClaimedId, se);

        return new MockIdentifier(opIdentifier, new ServiceEndpoint[] { se });
    }
Exemplo n.º 15
0
 internal static MockIdentifier GetMockOPIdentifier(Scenarios scenario, UriIdentifier expectedClaimedId)
 {
     return GetMockOPIdentifier(scenario, expectedClaimedId, false, false);
 }
Exemplo n.º 16
0
 internal static MockIdentifier GetMockIdentifier(Scenarios scenario, ProtocolVersion providerVersion, bool useSsl)
 {
     ServiceEndpoint se = GetServiceEndpoint(scenario, providerVersion, 10, useSsl);
     return new MockIdentifier(GetIdentityUrl(scenario, providerVersion, useSsl), new ServiceEndpoint[] { se });
 }
        public async Task <IActionResult> Get(string iata)
        {
            var result = await _mediator.ExecuteAsync(Scenarios.GetAirportInformation(iata));

            return(result.ToObjectResult());
        }
Exemplo n.º 18
0
 public static Identifier GetDelegateUrl(Scenarios scenario, bool useSsl)
 {
     return new UriIdentifier(GetFullUrl("/" + scenario, null, useSsl));
 }
Exemplo n.º 19
0
 public void GivenICreatedCategory(string categoryName) => Scenarios.CreateCategory(categoryName);
Exemplo n.º 20
0
        public void OnTimer()
        {
            try
            {
                if (StoryProgression.Main == null)
                {
                    return;
                }

                Scenarios.IncStat("OnTimer Try");

                if (mInTimer)
                {
                    return;
                }

                mWatch.Restart();

                try
                {
                    mInTimer = true;

                    mRunning = true;

                    if (GetValue <ShowStartScreenOption, bool>())
                    {
                        FilePersistence.ImportFromTuning("NRaas.StoryProgression.Tuning");

                        if (!GetValue <ProgressionOption, bool>())
                        {
                            if (AcceptCancelDialog.Show(Localize("Welcome")))
                            {
                                GetOption <ProgressionOption>().SetValue(true);

                                new InitialHomelessScenario().Post(Households, true, false);
                            }
                        }
                    }

                    GetOption <ShowStartScreenOption>().SetValue(false);

                    if (GetValue <ProgressionOption, bool>())
                    {
                        int currentInterval = LifeSpan.GetHumanAgeSpanLength();

                        if (GetValue <LastAskedIntervalOption, int>() != currentInterval)
                        {
                            if (AcceptCancelDialog.Show(Localize("AgeSpan")))
                            {
                                AdjustSpeedForAgeSpan((float)currentInterval / GetValue <SavedIntervalOption, int>());

                                GetOption <SavedIntervalOption>().SetValue(currentInterval);
                            }

                            GetOption <LastAskedIntervalOption>().SetValue(currentInterval);
                        }
                    }

                    Update(false, false);
                }
                finally
                {
                    mInTimer = false;
                }

                Scenarios.IncStat("OnTimer Complete");
            }
            catch (Exception exception)
            {
                Common.Exception(UnlocalizedName, exception);
            }
        }
        public async Task IssueCredentialThrowsExceptionCredentialInvalidState()
        {
            //Establish a connection between the two parties
            var(issuerConnection, holderConnection) = await Scenarios.EstablishConnectionAsync(
                _connectionService, _messages, _issuerWallet, _holderWallet);

            // Create an issuer DID/VK. Can also be created during provisioning
            var issuer = await Did.CreateAndStoreMyDidAsync(_issuerWallet.Wallet,
                                                            new { seed = TestConstants.StewardSeed }.ToJson());

            // Create a schema and credential definition for this issuer
            var(definitionId, _) = await Scenarios.CreateDummySchemaAndNonRevokableCredDef(_issuerWallet, _schemaService, issuer.Did,
                                                                                           new[] { "dummy_attr" });

            var offerConfig = new OfferConfiguration
            {
                IssuerDid = issuer.Did,
                CredentialDefinitionId = definitionId
            };

            // Send an offer to the holder using the established connection channel
            var(message, _) = await _credentialService.CreateOfferAsync(_issuerWallet, offerConfig, issuerConnection.Id);

            _messages.Add(message);

            // Holder retrieves message from their cloud agent
            var credentialOffer = FindContentMessage <CredentialOfferMessage>(_messages);

            // Holder processes the credential offer by storing it
            var holderCredentialId =
                await _credentialService.ProcessOfferAsync(_holderWallet, credentialOffer, holderConnection);

            // Holder creates master secret. Will also be created during wallet agent provisioning
            await AnonCreds.ProverCreateMasterSecretAsync(_holderWallet.Wallet, TestConstants.DefaultMasterSecret);

            // Holder accepts the credential offer and sends a credential request
            var(request, _) = await _credentialService.CreateRequestAsync(_holderWallet, holderCredentialId);

            _messages.Add(request);

            // Issuer retrieves credential request from cloud agent
            var credentialRequest = FindContentMessage <CredentialRequestMessage>(_messages);

            Assert.NotNull(credentialRequest);

            // Issuer processes the credential request by storing it
            var issuerCredentialId =
                await _credentialService.ProcessCredentialRequestAsync(_issuerWallet, credentialRequest, issuerConnection);

            // Issuer accepts the credential requests and issues a credential
            var(credential, _) = await _credentialService.CreateCredentialAsync(_issuerWallet, issuerCredentialId,
                                                                                new List <CredentialPreviewAttribute> {
                new CredentialPreviewAttribute("dummy_attr", "dummyVal")
            });

            _messages.Add(credential);

            //Try issue the credential again
            var ex = await Assert.ThrowsAsync <AriesFrameworkException>(async() => await _credentialService.CreateCredentialAsync(_issuerWallet, issuerCredentialId));

            Assert.True(ex.ErrorCode == ErrorCode.RecordInInvalidState);
        }
Exemplo n.º 22
0
 public void NavigateToProtocolPage()
 {
     Scenarios.SelectedIndex = 3;
     Scenarios.ScrollIntoView(Scenarios.SelectedItem);
     LoadScenario(scenarios[3].ClassType);
 }
Exemplo n.º 23
0
 internal static UriIdentifier GetIdentityUrl(Scenarios scenario, ProtocolVersion providerVersion)
 {
     return GetIdentityUrl(scenario, providerVersion, false);
 }
Exemplo n.º 24
0
 internal static UriIdentifier GetIdentityUrl(Scenarios scenario, ProtocolVersion providerVersion, bool useSsl)
 {
     return new UriIdentifier(GetFullUrl("/" + identityPage, new Dictionary<string, string> {
         { "user", scenario.ToString() },
         { "version", providerVersion.ToString() },
     }, useSsl));
 }
Exemplo n.º 25
0
 public void NavigateToFilePage()
 {
     Scenarios.SelectedIndex = 2;
     Scenarios.ScrollIntoView(Scenarios.SelectedItem);
     LoadScenario(scenarios[2].ClassType);
 }
Exemplo n.º 26
0
        /*
         * This function takes in a boolean value and returns a list of scenarios where the approved
         * status of the scenario matches that of the input value.
         */

        public static Scenarios getScenarios(bool approved, SqlConnection connection)
        {
            var scenarios = new Scenarios {
                ScenarioList = new List <Scenario>()
            };

            try
            {
                var command = new SqlCommand(null, connection)
                {
                    CommandText = "SELECT * " +
                                  "FROM SCENARIOS JOIN STUDENTS ON SCENARIOS.SCENARIO_MADE_BY = STUDENTS.STUDENT_ID " +
                                  "WHERE SCENARIO_ID != 0 AND SCENARIO_APPROVED = 1"
                };
                if (!approved)
                {
                    command.CommandText = "SELECT * " +
                                          "FROM SCENARIOS JOIN STUDENTS ON SCENARIOS.SCENARIO_MADE_BY = STUDENTS.STUDENT_ID " +
                                          "WHERE SCENARIO_ID != 0 AND SCENARIO_APPROVED = 0";
                }

                // Create and prepare an SQL statement.
                // Call Prepare after setting the Commandtext and Parameters.
                connection.Close(); connection.Open();
                command.Prepare();
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var scenario = new Scenario();
                        scenario.scenarioName         = $"{reader["SCENARIO_NAME"]}";
                        scenario.scenarioID           = Convert.ToInt32($"{reader["SCENARIO_ID"]}");
                        scenario.description          = $"{reader["SCENARIO_DESCRIPTION"]}";
                        scenario.isActive             = Convert.ToBoolean($"{reader["SCENARIO_IS_ACTIVE"]}".ToLower());
                        scenario.madeBy               = $"{reader["STUDENT_NAME"]}";
                        scenario.cellFunction         = $"{reader["SCENARIO_CELL_FUNCTION"]}";
                        scenario.cellShapeAndFeatures = $"{reader["SCENARIO_CELL_SHAPE_AND_FEATURES"]}";
                        scenario.cellLifespan         = $"{reader["SCENARIO_CELL_LIFESPAN"]}";
                        scenario.cellNutrition        = $"{reader["SCENARIO_CELL_NUTRITION"]}";
                        if ($"{reader["SCENARIO_FIRST_QUESTION"]}".Equals(""))
                        {
                            scenario.currentQuestion = 0;
                        }
                        else
                        {
                            scenario.currentQuestion = Convert.ToInt32($"{reader["SCENARIO_FIRST_QUESTION"]}");
                        }
                        scenarios.ScenarioList.Add(scenario);
                    }
                }
            }
            catch (Exception ex)
            {
                Singleton.errorCode = "SEN08";
                Singleton.writeErrorToFile(Singleton.errorCode, ex.Message, ex.StackTrace);
                throw ex;
            }
            finally
            {
                connection.Close();
            }

            return(scenarios);
        }
Exemplo n.º 27
0
 private void GoToTheNextScenarioButtonMethod(Scenarios scenarios)
 {
     GoToScenario(scenarios);
 }
Exemplo n.º 28
0
        public static (UpdateUser, IUpdateUserResult, UpdateUserHandlerDependencies) SetupForScenario(Scenarios scenario)
        {
            var request          = GetRequestForScenario(scenario);
            var expectedResponse = GetExpectedResultForScenario(scenario, request);
            var dependencies     = ConfigureDependenciesForScenario(request, expectedResponse);

            return(request, expectedResponse, dependencies);
        }
 public ScenarioBase[] GetDependentScenarios(Type[] types)
 {
     return(Scenarios
            .Where(x => x.GetAllUsedActionTypes()
                   .Any(z => types.Any(y => y.Equals(z)))).ToArray());
 }
Exemplo n.º 30
0
 private static UpdateUser GetRequestForScenario(Scenarios scenario) =>
 scenario switch
 {
Exemplo n.º 31
0
        public async Task AcceptProofRequestCredentialInvalidState()
        {
            //Setup a connection and issue the credentials to the holder
            var(issuerConnection, holderConnection) = await Scenarios.EstablishConnectionAsync(
                _connectionService, _messages, _issuerWallet, _holderWallet);

            await Scenarios.IssueCredentialAsync(
                _schemaService, _credentialService, _messages, issuerConnection,
                holderConnection, _issuerWallet, _holderWallet, await _holderWallet.Pool, TestConstants.DefaultMasterSecret, true, new List <CredentialPreviewAttribute>
            {
                new CredentialPreviewAttribute("first_name", "Test"),
                new CredentialPreviewAttribute("last_name", "Holder")
            });

            _messages.Clear();

            //Requestor initialize a connection with the holder
            var(_, requestorConnection) = await Scenarios.EstablishConnectionAsync(
                _connectionService, _messages, _holderWallet, _requestorWallet);

            // Verifier sends a proof request to prover
            {
                var proofRequestObject = new ProofRequest
                {
                    Name                = "ProofReq",
                    Version             = "1.0",
                    Nonce               = "123",
                    RequestedAttributes = new Dictionary <string, ProofAttributeInfo>
                    {
                        { "first-name-requirement", new ProofAttributeInfo {
                              Name = "first_name"
                          } }
                    }
                };

                //Requestor sends a proof request
                var(message, _) = await _proofService.CreateProofRequestAsync(_requestorWallet, proofRequestObject, requestorConnection.Id);

                _messages.Add(message);
            }

            // Holder accepts the proof requests and builds a proof
            //Holder retrives proof request message from their cloud agent
            var proofRequest = FindContentMessage <ProofRequestMessage>();

            Assert.NotNull(proofRequest);

            //Holder stores the proof request
            var holderProofRequestId = await _proofService.ProcessProofRequestAsync(_holderWallet, proofRequest, holderConnection);

            var holderProofRecord = await _proofService.GetAsync(_holderWallet, holderProofRequestId);

            var holderProofObject =
                JsonConvert.DeserializeObject <ProofRequest>(holderProofRecord.RequestJson);

            var requestedCredentials = new RequestedCredentials();

            foreach (var requestedAttribute in holderProofObject.RequestedAttributes)
            {
                var credentials =
                    await _proofService.ListCredentialsForProofRequestAsync(_holderWallet, holderProofObject,
                                                                            requestedAttribute.Key);

                requestedCredentials.RequestedAttributes.Add(requestedAttribute.Key,
                                                             new RequestedAttribute
                {
                    CredentialId = credentials.First().CredentialInfo.Referent,
                    Revealed     = true,
                    Timestamp    = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
                });
            }

            foreach (var requestedAttribute in holderProofObject.RequestedPredicates)
            {
                var credentials =
                    await _proofService.ListCredentialsForProofRequestAsync(_holderWallet, holderProofObject,
                                                                            requestedAttribute.Key);

                requestedCredentials.RequestedPredicates.Add(requestedAttribute.Key,
                                                             new RequestedAttribute
                {
                    CredentialId = credentials.First().CredentialInfo.Referent,
                    Revealed     = true
                });
            }

            //Holder accepts the proof request and sends a proof
            await _proofService.CreateProofAsync(_holderWallet, holderProofRequestId, requestedCredentials);

            var ex = await Assert.ThrowsAsync <AgentFrameworkException>(async() => await _proofService.CreateProofAsync(_holderWallet, holderProofRequestId,
                                                                                                                        requestedCredentials));

            Assert.True(ex.ErrorCode == ErrorCode.RecordInInvalidState);
        }
Exemplo n.º 32
0
 public DebugInfoPageMiddleware(RequestDelegate next, IServerAddressesFeature serverAddresses, IHostingEnvironment hostingEnv, Scenarios scenarios)
 {
     _next            = next;
     _hostingEnv      = hostingEnv;
     _scenarios       = scenarios;
     _serverAddresses = serverAddresses;
 }
Exemplo n.º 33
0
        public async Task <Scenarios> CreateAsync(Scenarios scenario)
        {
            await _scenarios.InsertOneAsync(scenario);

            return(scenario);
        }
Exemplo n.º 34
0
        public PageShowScenario()
        {
            this.AllScenarios = Scenarios.GetScenarios();

            InitializeComponent();
        }
        public async Task CanConductChallengeFlow()
        {
            //Setup a connection and issue the credentials to the holder
            var(issuerConnection, holderConnection) = await Scenarios.EstablishConnectionAsync(
                _connectionService, _messages, _issuerWallet, _holderWallet);

            await Scenarios.IssueCredentialAsync(
                _schemaService, _credentialService, _messages, issuerConnection,
                holderConnection, _issuerWallet, _holderWallet, await _holderWallet.Pool, TestConstants.DefaultMasterSecret, true, new List <CredentialPreviewAttribute>
            {
                new CredentialPreviewAttribute("first_name", "Test"),
                new CredentialPreviewAttribute("last_name", "Holder")
            });

            _messages.Clear();

            // Challenger sends a challenge
            {
                var challengeConfig = new EphemeralChallengeConfiguration
                {
                    Name     = "Test",
                    Type     = ChallengeType.Proof,
                    Contents = new ProofRequestConfiguration
                    {
                        RequestedAttributes = new Dictionary <string, ProofAttributeInfo>
                        {
                            { "first-name-requirement", new ProofAttributeInfo {
                                  Name = "first_name"
                              } }
                        }
                    }
                };

                var challengeConfigId = await _ephemeralChallengeService.CreateChallengeConfigAsync(_requestorWallet, challengeConfig);

                (var challenge, var record) = await _ephemeralChallengeService.CreateChallengeAsync(_requestorWallet, challengeConfigId);

                Assert.True(!string.IsNullOrEmpty(challenge.ChallengerName));
                Assert.True(challenge.RecipientKeys.Count() == 1);
                Assert.True(challenge.RecipientKeys.First() == TestConstants.DefaultVerkey);
                Assert.True(challenge.ServiceEndpoint == TestConstants.DefaultMockUri);

                _messages.Add(challenge);

                var result = await _ephemeralChallengeService.GetChallengeStateAsync(_requestorWallet, record.Id);

                Assert.True(result == ChallengeState.Challenged);
            }

            //Challenge responder recieves challenge
            {
                var challengeMessage = _messages.OfType <EphemeralChallengeMessage>().First();

                var proofRequest = challengeMessage.Challenge.Contents.ToObject <ProofRequest>();

                var requestedCredentials = new RequestedCredentials();
                foreach (var requestedAttribute in proofRequest.RequestedAttributes)
                {
                    var credentials =
                        await _proofService.ListCredentialsForProofRequestAsync(_holderWallet, proofRequest,
                                                                                requestedAttribute.Key);

                    requestedCredentials.RequestedAttributes.Add(requestedAttribute.Key,
                                                                 new RequestedAttribute
                    {
                        CredentialId = credentials.First().CredentialInfo.Referent,
                        Revealed     = true,
                        Timestamp    = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
                    });
                }

                foreach (var requestedAttribute in proofRequest.RequestedPredicates)
                {
                    var credentials =
                        await _proofService.ListCredentialsForProofRequestAsync(_holderWallet, proofRequest,
                                                                                requestedAttribute.Key);

                    requestedCredentials.RequestedPredicates.Add(requestedAttribute.Key,
                                                                 new RequestedAttribute
                    {
                        CredentialId = credentials.First().CredentialInfo.Referent,
                        Revealed     = true
                    });
                }

                var challenge = await _ephemeralChallengeService.CreateProofChallengeResponseAsync(
                    _holderWallet, challengeMessage, requestedCredentials);

                _messages.Add(challenge);
            }

            //Challenger recieves challenge response and verifies it
            {
                var challengeResponseMessage = _messages.OfType <EphemeralChallengeResponseMessage>().First();

                var id = await _ephemeralChallengeService.ProcessChallengeResponseAsync(_requestorWallet, challengeResponseMessage);

                var result = await _ephemeralChallengeService.GetChallengeStateAsync(_requestorWallet, id);

                Assert.True(result == ChallengeState.Accepted);
            }
        }
Exemplo n.º 36
0
 /// <summary>
 /// Vide les propriétés de navigation.
 /// </summary>
 protected virtual void ClearNavigationProperties()
 {
     LongLabelResource  = null;
     ShortLabelResource = null;
     Scenarios.Clear();
 }
Exemplo n.º 37
0
        /// <summary>
        /// An asynchronous task that attempts to initiate a new call to a listening UAS.
        /// </summary>
        /// <param name="sipTransport">The transport object to use for the send.</param>
        /// <param name="dst">The destination end point to send the request to.</param>
        /// <returns>True if the expected response was received, false otherwise.</returns>
        private static async Task <bool> InitiateCallTaskAsync(SIPTransport sipTransport, SIPURI dst, Scenarios scenario)
        {
            //UdpClient hepClient = new UdpClient(0, AddressFamily.InterNetwork);

            try
            {
                //sipTransport.SIPRequestOutTraceEvent += (localEP, remoteEP, req) =>
                //{
                //    logger.LogDebug($"Request sent: {localEP}->{remoteEP}");
                //    logger.LogDebug(req.ToString());

                //    //var hepBuffer = HepPacket.GetBytes(localEP, remoteEP, DateTimeOffset.Now, 333, "myHep", req.ToString());
                //    //hepClient.SendAsync(hepBuffer, hepBuffer.Length, "192.168.11.49", 9060);
                //};

                //sipTransport.SIPResponseInTraceEvent += (localEP, remoteEP, resp) =>
                //{
                //    logger.LogDebug($"Response received: {localEP}<-{remoteEP}");
                //    logger.LogDebug(resp.ToString());

                //    //var hepBuffer = HepPacket.GetBytes(remoteEP, localEP, DateTimeOffset.Now, 333, "myHep", resp.ToString());
                //    //hepClient.SendAsync(hepBuffer, hepBuffer.Length, "192.168.11.49", 9060);
                //};

                var ua = new SIPUserAgent(sipTransport, null);
                ua.ClientCallTrying   += (uac, resp) => logger.LogInformation($"{uac.CallDescriptor.To} Trying: {resp.StatusCode} {resp.ReasonPhrase}.");
                ua.ClientCallRinging  += (uac, resp) => logger.LogInformation($"{uac.CallDescriptor.To} Ringing: {resp.StatusCode} {resp.ReasonPhrase}.");
                ua.ClientCallFailed   += (uac, err, resp) => logger.LogWarning($"{uac.CallDescriptor.To} Failed: {err}");
                ua.ClientCallAnswered += (uac, resp) => logger.LogInformation($"{uac.CallDescriptor.To} Answered: {resp.StatusCode} {resp.ReasonPhrase}.");

                var audioOptions = new AudioSourceOptions {
                    AudioSource = AudioSourcesEnum.Silence
                };
                var audioExtrasSource = new AudioExtrasSource(new AudioEncoder(), audioOptions);
                audioExtrasSource.RestrictFormats(format => format.Codec == AudioCodecsEnum.PCMU);
                var voipMediaSession = new VoIPMediaSession(new MediaEndPoints {
                    AudioSource = audioExtrasSource
                });

                var result = await ua.Call(dst.ToString(), null, null, voipMediaSession);

                if (scenario == Scenarios.uacw)
                {
                    // Wait for the remote party to hangup the call.
                    logger.LogDebug("Waiting for the remote party to hangup the call...");

                    ManualResetEvent hangupMre = new ManualResetEvent(false);
                    ua.OnCallHungup += (dialog) => hangupMre.Set();

                    hangupMre.WaitOne();

                    logger.LogDebug("Call hungup by remote party.");
                }
                else
                {
                    // We hangup the call after 1s.
                    await Task.Delay(1000);

                    ua.Hangup();
                }

                // Need a bit of time for the BYE to complete.
                await Task.Delay(500);

                return(result);
            }
            catch (Exception excp)
            {
                logger.LogError($"Exception InitiateCallTaskAsync. {excp.Message}");
                return(false);
            }
        }
Exemplo n.º 38
0
        public async Task CreateProofRequestFromProposal()
        {
            var events = 0;

            _eventAggregator.GetEventByType <ServiceMessageProcessingEvent>()
            .Where(_ => (_.MessageType == MessageTypes.PresentProofNames.ProposePresentation ||
                         _.MessageType == MessageTypes.PresentProofNames.RequestPresentation ||
                         _.MessageType == MessageTypes.IssueCredentialNames.RequestCredential ||
                         _.MessageType == MessageTypes.IssueCredentialNames.IssueCredential))
            .Subscribe(_ =>
            {
                events++;
            });

            // Setup secure connection between issuer and holder
            var(issuerConnection, holderConnection) = await Scenarios.EstablishConnectionAsync(
                _connectionService, _messages, _issuerWallet, _holderWallet);

            var(issuerCredential, holderCredential) = await Scenarios.IssueCredentialAsync(
                _schemaService, _credentialService, _messages, issuerConnection,
                holderConnection, _issuerWallet, _holderWallet, await _holderWallet.Pool, TestConstants.DefaultMasterSecret, false, new List <CredentialPreviewAttribute>
            {
                new CredentialPreviewAttribute("first_name", "Test"),
                new CredentialPreviewAttribute("last_name", "Test"),
                new CredentialPreviewAttribute("salary", "100000"),
                new CredentialPreviewAttribute("age", "25"),
                new CredentialPreviewAttribute("wellbeing", "100")
            });



            Assert.Equal(issuerCredential.State, holderCredential.State);
            Assert.Equal(CredentialState.Issued, issuerCredential.State);
            var(message, record) = await _proofService.CreateProposalAsync(_holderWallet, new ProofProposal
            {
                Comment            = "Hello, World",
                ProposedAttributes = new List <ProposedAttribute>
                {
                    new ProposedAttribute
                    {
                        Name = "first_name",
                        CredentialDefinitionId = holderCredential.CredentialDefinitionId,
                        Referent = "Proof of Name",
                        Value    = "Joe"
                    },
                    new ProposedAttribute
                    {
                        Name = "last_name",
                        CredentialDefinitionId = holderCredential.CredentialDefinitionId,
                        Referent = "Proof of Name",
                        Value    = "Shmoe"
                    },
                    new ProposedAttribute
                    {
                        Name = "age",
                        CredentialDefinitionId = holderCredential.CredentialDefinitionId,
                        Referent = "Proof of Age",
                        Value    = "Shmoe"
                    }
                },
                ProposedPredicates = new List <ProposedPredicate>
                {
                    new ProposedPredicate
                    {
                        Name = "salary",
                        CredentialDefinitionId = holderCredential.CredentialDefinitionId,
                        Predicate = ">",
                        Threshold = 99999,
                        Referent  = "Proof of Salary > $99,999"
                    },
                    new ProposedPredicate
                    {
                        Name = "wellbeing",
                        CredentialDefinitionId = holderCredential.CredentialDefinitionId,
                        Referent  = "Proof of Wellbeing",
                        Predicate = "<",
                        Threshold = 99999
                    }
                }
            }, holderConnection.Id);

            Assert.NotNull(message);

            // Process Proposal
            record = await _proofService.ProcessProposalAsync(_issuerWallet, message, issuerConnection);

            //
            RequestPresentationMessage requestMessage;

            (requestMessage, record) = await _proofService.CreateRequestFromProposalAsync(_issuerWallet, new ProofRequestParameters
            {
                Name       = "Test",
                Version    = "1.0",
                NonRevoked = null
            }, record.Id, issuerConnection.Id);

            Assert.NotNull(requestMessage);
            Assert.NotNull(record);

            var actualProofRequest   = record.RequestJson.ToObject <ProofRequest>();
            var expectedProofRequest = new ProofRequest
            {
                Name                = "Test",
                Version             = "1.0",
                Nonce               = actualProofRequest.Nonce,
                RequestedAttributes = new Dictionary <string, ProofAttributeInfo>
                {
                    {
                        "Proof of Name", new ProofAttributeInfo
                        {
                            Name         = null,
                            Names        = new string[] { "first_name", "last_name" },
                            NonRevoked   = null,
                            Restrictions = new List <AttributeFilter>
                            {
                                new AttributeFilter
                                {
                                    CredentialDefinitionId = holderCredential.CredentialDefinitionId
                                }
                            }
                        }
                    },
                    {
                        "Proof of Age", new ProofAttributeInfo
                        {
                            Name         = "age",
                            Names        = null,
                            NonRevoked   = null,
                            Restrictions = new List <AttributeFilter>
                            {
                                new AttributeFilter
                                {
                                    CredentialDefinitionId = holderCredential.CredentialDefinitionId
                                }
                            }
                        }
                    }
                },
                RequestedPredicates = new Dictionary <string, ProofPredicateInfo>
                {
                    {
                        "Proof of Salary > $99,999", new ProofPredicateInfo
                        {
                            Name           = "salary",
                            Names          = null,
                            NonRevoked     = null,
                            PredicateType  = ">",
                            PredicateValue = 99999,
                            Restrictions   = new List <AttributeFilter>
                            {
                                new AttributeFilter
                                {
                                    CredentialDefinitionId = holderCredential.CredentialDefinitionId
                                }
                            }
                        }
                    },
                    {
                        "Proof of Wellbeing", new ProofPredicateInfo
                        {
                            Name           = "wellbeing",
                            Names          = null,
                            NonRevoked     = null,
                            PredicateType  = "<",
                            PredicateValue = 99999,
                            Restrictions   = new List <AttributeFilter>
                            {
                                new AttributeFilter
                                {
                                    CredentialDefinitionId = holderCredential.CredentialDefinitionId
                                }
                            }
                        }
                    }
                }
            };
            var expectedProofRecord = new ProofRecord
            {
                State       = ProofState.Requested,
                RequestJson = expectedProofRequest.ToJson(),
            };

            actualProofRequest.Should().BeEquivalentTo(expectedProofRequest);
        }
        public PagePlayScenario()
        {
            InitializeComponent();

            popUpSplash = new Popup();

            popUpSplash.Child           = UICreator.CreateSplashWindow();
            popUpSplash.Placement       = PlacementMode.Center;
            popUpSplash.PlacementTarget = PageNavigator.MainWindow;
            popUpSplash.IsOpen          = false;

            StackPanel panelContent = new StackPanel();

            panelContent.Margin = new Thickness(10, 0, 10, 0);
            panelContent.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;

            WrapPanel panelScenarios = new WrapPanel();

            panelContent.Children.Add(panelScenarios);

            StackPanel panelSelectScenarios = new StackPanel();

            panelScenarios.Children.Add(panelSelectScenarios);

            TextBlock txtHeader = new TextBlock();

            txtHeader.Width = 200;
            txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeader.FontWeight    = FontWeights.Bold;
            txtHeader.Uid           = "1001";
            txtHeader.TextAlignment = TextAlignment.Center;
            txtHeader.Text          = Translator.GetInstance().GetString("PagePlayScenario", txtHeader.Uid);
            panelSelectScenarios.Children.Add(txtHeader);

            ListBox lbScenarios = new ListBox();

            lbScenarios.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbScenarios.Height       = GraphicsHelpers.GetContentHeight() / 2;
            lbScenarios.ItemTemplate = this.Resources["ScenarioItem"] as DataTemplate;
            lbScenarios.Width        = 200;


            foreach (Scenario scenario in Scenarios.GetScenarios())
            {
                lbScenarios.Items.Add(scenario);
            }

            panelSelectScenarios.Children.Add(lbScenarios);

            panelScenarios.Children.Add(createScenarioPanel());

            Button btnExit = new Button();

            btnExit.SetResourceReference(Button.StyleProperty, "RoundedButton");
            btnExit.Height              = double.NaN;
            btnExit.Width               = double.NaN;
            btnExit.Uid                 = "200";
            btnExit.Content             = Translator.GetInstance().GetString("PagePlayScenario", btnExit.Uid);
            btnExit.Margin              = new Thickness(0, 10, 0, 0);
            btnExit.Click              += btnExit_Click;
            btnExit.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            btnExit.SetResourceReference(Button.BackgroundProperty, "ButtonBrush");
            panelContent.Children.Add(btnExit);



            base.setTopMenu(new PageTopMenu());

            base.hideNavigator();

            base.hideBottomMenu();

            base.setContent(panelContent);

            base.setHeaderContent(Translator.GetInstance().GetString("PagePlayScenario", "1000"));



            showPage(this);
        }
Exemplo n.º 40
0
        public async Task CreateProofProposalSuccesfully()
        {
            var proposedAttributes = new List <ProposedAttribute>
            {
                new ProposedAttribute
                {
                    Name = "first_name",
                    CredentialDefinitionId = "1",
                    SchemaId  = "1",
                    IssuerDid = "1",
                    Referent  = "Proof of Name",
                    Value     = "Joe"
                },
                new ProposedAttribute
                {
                    Name = "second_name",
                    CredentialDefinitionId = "1",
                    SchemaId  = "1",
                    IssuerDid = "1",
                    Referent  = "Proof of Name",
                    Value     = "Joe"
                },
                new ProposedAttribute
                {
                    Name = "age",
                    CredentialDefinitionId = "1",
                    SchemaId  = "1",
                    IssuerDid = "1",
                    Referent  = "Proof of Age",
                    Value     = "Joe"
                }
            };
            var proposedPredicates =
                new List <ProposedPredicate>
            {
                new ProposedPredicate
                {
                    Name = "salary",
                    CredentialDefinitionId = "1",
                    Predicate = ">",
                    Threshold = 99999,
                    Referent  = "Proof of Salary > $99,999"
                },
                new ProposedPredicate
                {
                    Name = "test",
                    CredentialDefinitionId = "1",
                    Predicate = ">",
                    Threshold = 99999,
                    Referent  = "Proof of Test > $99,999"
                }
            };

            var(issuerConnection, holderConnection) = await Scenarios.EstablishConnectionAsync(
                _connectionService, _messages, _issuerWallet, _holderWallet);

            var proofProposal = new ProofProposal
            {
                Comment            = "Hello, World",
                ProposedAttributes = proposedAttributes,
                ProposedPredicates = proposedPredicates
            };

            var(message, record) = await _proofService.CreateProposalAsync(_holderWallet, proofProposal, holderConnection.Id);

            var expectedMessage = new ProposePresentationMessage
            {
                Id      = message.Id,
                Comment = "Hello, World",
                PresentationPreviewMessage = new PresentationPreviewMessage
                {
                    Id = message.PresentationPreviewMessage.Id,
                    ProposedAttributes = proposedAttributes.ToArray(),
                    ProposedPredicates = proposedPredicates.ToArray()
                }
            };

            message.Should().BeEquivalentTo(expectedMessage);
        }
Exemplo n.º 41
0
 public List <ScenarioResult> ScenariosByStatus(ExecutionStatus status)
 {
     return(Scenarios.Where(s => s.Status == status).ToList());
 }
Exemplo n.º 42
0
        public async Task CreateProofProposalThrowsInvalidParameterFormat()
        {
            // Setup secure connection between issuer and holder
            var(issuerConnection, holderConnection) = await Scenarios.EstablishConnectionAsync(
                _connectionService, _messages, _issuerWallet, _holderWallet);

            var proofProposal = new ProofProposal
            {
                Comment            = "Hello, World",
                ProposedAttributes = new List <ProposedAttribute>
                {
                    new ProposedAttribute
                    {
                        Name = "first_name",
                        CredentialDefinitionId = "1",
                        SchemaId  = "1",
                        IssuerDid = "1",
                        Referent  = "Proof of First Name",
                        Value     = "Joe"
                    },
                    new ProposedAttribute
                    {
                        Name = "second_name",
                        CredentialDefinitionId = "2",
                        SchemaId  = "2",
                        IssuerDid = "2",
                        Referent  = "Proof of First Name",
                        Value     = "Joe"
                    }
                },
                ProposedPredicates = new List <ProposedPredicate>
                {
                    new ProposedPredicate
                    {
                        Name = "salary",
                        CredentialDefinitionId = "1",
                        Predicate = ">",
                        Threshold = 99999,
                        Referent  = "Proof of Salary > $99,999"
                    }
                }
            };

            var ex = await Assert.ThrowsAsync <AriesFrameworkException>(async() =>
                                                                        await _proofService.CreateProposalAsync(_holderWallet, proofProposal, holderConnection.Id));

            Assert.True(ex.ErrorCode == ErrorCode.InvalidParameterFormat);

            var len = proofProposal.ProposedAttributes.Count - 1;

            proofProposal.ProposedAttributes.Remove(proofProposal.ProposedAttributes[len]);
            proofProposal.ProposedPredicates.Add(new ProposedPredicate
            {
                Name = "name",
                CredentialDefinitionId = "2",
                Predicate = ">",
                Threshold = 99999,
                Referent  = "Proof of Salary > $99,999"
            });

            ex = await Assert.ThrowsAsync <AriesFrameworkException>(async() =>
                                                                    await _proofService.CreateProposalAsync(_holderWallet, proofProposal, holderConnection.Id));

            Assert.True(ex.ErrorCode == ErrorCode.InvalidParameterFormat);
        }
Exemplo n.º 43
0
 public StoryTests() :
     base(Scenarios.OfStories(eventStore => Stories.OfUseCases(
                                  new CustomerUseCases(new Repository <Customer.State>(eventStore))
                                  )))
 {
 }
Exemplo n.º 44
0
        public ShellbagScenarioViewModel(Shellbag shellbag) : base()
        {
            DisplayName = "Shellbags";

            Scenarios.Add(shellbag);
        }
 public void Add(Scenarios.TransmissionLoss transmissionLoss, double bearing)
 {
     var geoRect = (GeoRect)transmissionLoss.AnalysisPoint.Scenario.Location.GeoRect;
     var segment = new GeoSegment(transmissionLoss.AnalysisPoint.Geo, transmissionLoss.Modes[0].MaxPropagationRadius, bearing);
     if (!geoRect.Contains(segment[0]) || !geoRect.Contains(segment[1]))
     {
         //radial.Errors.Add("This radial extends beyond the location boundaries");
         return;
     }
     //Debug.WriteLine("{0}: Queueing calculation of transmission loss for radial bearing {1} degrees, of mode {2} in analysis point {3}", DateTime.Now, radial.Bearing, radial.TransmissionLoss.Mode.ModeName, (Geo)radial.TransmissionLoss.AnalysisPoint.Geo); 
     Radial outRadial;
     if (WorkQueue.TryGetValue(radial.Guid, out outRadial)) return;
     WorkQueue.Add(radial.Guid, radial);
     _calculatorQueue.Post(radial);
 }
Exemplo n.º 46
0
    internal static DotNetOpenId.RelyingParty.IAuthenticationRequest CreateRelyingPartyRequest(bool stateless, Scenarios scenario, ProtocolVersion version)
    {
        // Publish RP discovery information
        MockHttpRequest.RegisterMockRPDiscovery();

        var rp = TestSupport.CreateRelyingParty(stateless ? null : RelyingPartyStore, null);
        var rpReq = rp.CreateRequest(TestSupport.GetMockIdentifier(scenario, version), Realm, ReturnTo);

        {
            // Sidetrack: verify URLs and other default properties
            Assert.AreEqual(AuthenticationRequestMode.Setup, rpReq.Mode);
            Assert.AreEqual(Realm, rpReq.Realm);
            Assert.AreEqual(ReturnTo, rpReq.ReturnToUrl);
        }

        return rpReq;
    }